1 Reply Latest reply on Oct 27, 2005 3:59 PM by Boleslaw Dawidowicz

    portlets upload file problem

    Stefan Smadici Newbie

      i have this jsp:
      <html:form action="/blsincro" method="post"

      Please Enter the
      Following Details

      <html:errors />

      File Name
      <html:file property="file" />

      <html:submit>Upload File</html:submit> <html:submit property="doIt">DoIt</html:submit>


      and my action class is:
      public class myAction extends BaseAction {

      protected ActionForward perform(ActionMapping mapping, ActionForm dynaForm,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {



      The class "BaseAction" extends the "Action" class; i use portlets and JBoss portal.

      ... the problem is: i cant reach the "uploaded" file into my action class; my action is executing, but file is allways "null"; the second problem is: the property "doIt" that must be on "request" isnt there!

        • 1. Re: portlets upload file problem
          Boleslaw Dawidowicz Master

          When you have multipart form data your params will not be in params map directly but in multipart content along with file data. Use apache commons lib for this and try code below:

          import org.apache.commons.fileupload.disk.DiskFileItemFactory;
          import org.apache.commons.fileupload.portlet.PortletFileUpload;
          import org.apache.commons.fileupload.FileItem;
          import org.apache.commons.fileupload.FileUploadException;

          DiskFileItemFactory factory = new DiskFileItemFactory();
          PortletFileUpload upload = new PortletFileUpload(factory);
           for (Iterator i = upload.parseRequest(req).iterator(); i.hasNext();)
           FileItem item = (FileItem)i.next();
           //for normal fields put them into request params map
           if (item.isFormField())
           req.getParameterMap().put(item.getFieldName(), new String[]{item.getString()});
           if (item.getSize() != 0)
           /**here you can access file uploaded using:

          I hope this will help you.