Help Regarding File Upload Portlet

View: New views
2 Messages — Rating Filter:   Alert me  

Help Regarding File Upload Portlet

by globus world :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HI all,

i am developing a simple file upload portlet . please help me regarding this.my code is like this .

     I am using gridsphere2.2.10 + tomcat 5.5.25 +ant 1.7.1 + jdk  1.6
Jsp

<%@ page session="true" contentType="text/html"%>
<jsp:useBean id="url" class="java.lang.String" scope="request"/>
<jsp:useBean id="rurl" class="java.lang.String" scope="request"/>
<jsp:useBean id="vomses" class="java.lang.String" scope="request"/>

Welcome <b><%= vomses%> ! <%= url %>  <%= rurl %></b>
<form  method="POST" action="<%= url %>" >
    <table>
        <tr>
             <td>
                    Vomses
            </td>
            <td>
                       <input type="File" name="vomses"  size="15">
            </td>
        </tr>

        <tr>
            <td align="center"><input type="submit" value="Upload"/></td>
        </tr>
    </table>
</form>


Java is

package org.gridlab.gridsphere.jsrtutorial.portlets.helloworld;

import java.io.*;
import javax.portlet.*;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.portlet.*;
import org.apache.commons.fileupload.disk.*;
import java.util.*;

public  class ActionHelloWorld extends GenericPortlet {

    public void init(PortletConfig config)
     throws PortletException {
        super.init(config);
        getPortletContext().log("inside init method of portlet");
    }
   public void processAction(ActionRequest req, ActionResponse res) throws PortletException, IOException {
        String vomses=req.getParameter("vomses");
        boolean isMultipart = PortletFileUpload.isMultipartContent(req);

        if(isMultipart)
                System.out.println("got success");
        else
                System.out.println("sorry");

                if(vomses!=null)  res.setRenderParameter("vomses",vomses);
    }

public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {

        String vomses = request.getParameter("vomses");
        if (vomses != null) request.setAttribute("vomses", vomses);

        // create action url
        PortletURL url = response.createActionURL();
        request.setAttribute("url", url.toString());

        // create action url

        PortletURL rurl = response.createRenderURL();
        rurl.setPortletMode(PortletMode.VIEW);
        request.setAttribute("rurl", rurl.toString());

        getPortletConfig().getPortletContext().getRequestDispatcher("/jsp/helloworld/actionhello.jsp").include(request, response);
    }
}

isMultipart value is coming false and displaying "sorry"  mesaage in log file


please help me regarding this


Thanks in advance
sagar



 

_______________________________________________
Gridsphere-users mailing list
Gridsphere-users@...
http://lists.gridsphere.org/mailman/listinfo/gridsphere-users

Parent Message unknown Re: Help Regarding File Upload Portlet

by globus world :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Fine i got solution
In jsp i forget to add a enctype="multipart/form-data"

Thanks and Regards
sagar

On Sat, Nov 7, 2009 at 1:30 AM, <gridsphere-users-request@...> wrote:
Send Gridsphere-users mailing list submissions to
       gridsphere-users@...

To subscribe or unsubscribe via the World Wide Web, visit
       http://lists.gridsphere.org/mailman/listinfo/gridsphere-users
or, via email, send a message with subject or body 'help' to
       gridsphere-users-request@...

You can reach the person managing the list at
       gridsphere-users-owner@...

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Gridsphere-users digest..."


Today's Topics:

  1. Help Regarding File Upload Portlet (globus world)


----------------------------------------------------------------------

Message: 1
Date: Fri, 6 Nov 2009 14:49:54 +0530
From: globus world <sagarglobusworld@...>
Subject: [Gridsphere-users] Help Regarding File Upload Portlet
To: gridsphere-users@...
Message-ID:
       <c89972a30911060119l198a3cbcq748ca081ba1360ad@...>
Content-Type: text/plain; charset="iso-8859-1"

HI all,

i am developing a simple file upload portlet . please help me regarding
this.my code is like this .

    I am using gridsphere2.2.10 + tomcat 5.5.25 +ant 1.7.1 + jdk  1.6
Jsp

<%@ page session="true" contentType="text/html"%>
<jsp:useBean id="url" class="java.lang.String" scope="request"/>
<jsp:useBean id="rurl" class="java.lang.String" scope="request"/>
<jsp:useBean id="vomses" class="java.lang.String" scope="request"/>

Welcome <b><%= vomses%> ! <%= url %>  <%= rurl %></b>
<form  method="POST" action="<%= url %>" >
   <table>
       <tr>
            <td>
                   Vomses
           </td>
           <td>
                      <input type="File" name="vomses"  size="15">
           </td>
       </tr>

       <tr>
           <td align="center"><input type="submit" value="Upload"/></td>
       </tr>
   </table>
</form>


Java is

package org.gridlab.gridsphere.jsrtutorial.portlets.helloworld;

import java.io.*;
import javax.portlet.*;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.portlet.*;
import org.apache.commons.fileupload.disk.*;
import java.util.*;

public  class ActionHelloWorld extends GenericPortlet {

   public void init(PortletConfig config)
    throws PortletException {
       super.init(config);
       getPortletContext().log("inside init method of portlet");
   }
  public void processAction(ActionRequest req, ActionResponse res) throws
PortletException, IOException {
       String vomses=req.getParameter("vomses");
       boolean isMultipart = PortletFileUpload.isMultipartContent(req);

       if(isMultipart)
               System.out.println("got success");
       else
               System.out.println("sorry");

               if(vomses!=null)  res.setRenderParameter("vomses",vomses);
   }

public void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException {

       String vomses = request.getParameter("vomses");
       if (vomses != null) request.setAttribute("vomses", vomses);

       // create action url
       PortletURL url = response.createActionURL();
       request.setAttribute("url", url.toString());

       // create action url

       PortletURL rurl = response.createRenderURL();
       rurl.setPortletMode(PortletMode.VIEW);
       request.setAttribute("rurl", rurl.toString());


getPortletConfig().getPortletContext().getRequestDispatcher("/jsp/helloworld/actionhello.jsp").include(request,
response);
   }
}

isMultipart value is coming false and displaying "sorry"  mesaage in log
file


please help me regarding this


Thanks in advance
sagar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.gridsphere.org/pipermail/gridsphere-users/attachments/20091106/b5d3e6ef/attachment-0001.html

------------------------------

_______________________________________________
Gridsphere-users mailing list
Gridsphere-users@...
http://lists.gridsphere.org/mailman/listinfo/gridsphere-users


End of Gridsphere-users Digest, Vol 39, Issue 2
***********************************************


_______________________________________________
Gridsphere-users mailing list
Gridsphere-users@...
http://lists.gridsphere.org/mailman/listinfo/gridsphere-users