3 Replies Latest reply on Nov 4, 2004 10:58 AM by chamcha

    Multipart encoding problem

    chamcha

      Hi developers,
      there is a problem in nukes1.1RC3. Take a look at the contructor of org.jboss.nukes.servlet.MultipartRequest. The parameters values are extracted from upload fields with the standard encoding, ignoring the configured character set. In fact, the zero parameters version of org.apache.commons.fileupload.FileItem is called.

      This is the code (with my comments in bold):

      public MultipartRequest(HttpServletRequest request, int sizeMax)
      throws FileUploadException
      {
      super(request);

      // Create a new file upload handler
      DiskFileUpload upload = new DiskFileUpload();

      // Set upload parameters
      upload.setSizeMax(sizeMax);
      upload.setSizeThreshold(sizeMax);
      upload.setRepositoryPath(System.getProperty("java.io.tmpdir"));

      // Get request parameters
      for (Enumeration en = request.getParameterNames();en.hasMoreElements();)
      {
      String name = (String)en.nextElement();
      parameters.put(name, request.getParameterValues(name));
      }

      // Merge with upload fields
      for (Iterator i = upload.parseRequest(request).iterator();i.hasNext();)
      {
      FileItem item = (FileItem)i.next();
      if (item.isFormField())
      {
      // NEXT LINE IS PROBABLY WRONG
      parameters.put(item.getFieldName(), new String[]{item.getString()});
      }
      else
      {
      files.put(item.getFieldName(), new UploadedFile(item.getContentType(), item.get()));
      }
      }
      }

      Thanks in advance,
      Marco

        • 1. Re: What about NNTP/Forums connectivity?
          chamcha

          I did not work on NNTP integration for forums.
          Now they are freezed until, nukes core finished.

          We still need a forum, the forums on jboss will
          be refactored to fit in nukes.

          NNTP integration might be considered later.

          julien

          • 2. Re: Multipart encoding problem

            I'm not sure this will help solve your problem, but there is file uploading code that might help out. Maybe you have already seen it. The web site is http://www.servlets.com/cos/index.html . It's from one of the O'Reilly books. I use the upload.war file contained in the downloadable cos-date.zip file to do file uploading to my servers. It's worked well for me. The zip file contains the source code too.

            Danny

            • 3. Re: Multipart encoding problem
              chamcha

              Hi ThorntonD,
              there is no need of oreally file upload since commons-fileupload works well. The problem is the nukes code. I've fix the problem passing the HttpRequest encoding to the FileItem.getString().

              Since I think this is a nukes bug. I'll submit it soon.

              Marco