glassfish
  1. glassfish
  2. GLASSFISH-16740

Unable to get "multipart/form-data" request parameters by HttpServletRequest#getParameter

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1.2_b15
    • Component/s: web_container
    • Labels:
      None

      Description

      The Java Servlet 3.0 Specification states:

      For parts with form-data as the Content-Disposition, but without a filename, the string value of the part will also be available via the getParameter / getParameterValues methods on HttpServletRequest, using the name of the part.

      But in GlassFish 3.1 I'm unable access non-file multipart/form-data parameters that way. Of course, I can get parameters using getParts, but a JSF implementation rely on ordinary HttpServletRequest parameters map and therefore currently can't process multipart/form-data postback requests.

      1. 20111214-GLASSFISH-16740.patch
        2 kB
        kchung

        Issue Links

          Activity

          Hide
          Ed Burns added a comment -

          New mojarra that has this:

          @Override
          public boolean containsKey(Object key)

          { System.out.println("debug: edburns: containsKey(" + key + "): " + request.getParameter(key.toString())); return (request.getParameter(key.toString()) != null); }
          Show
          Ed Burns added a comment - New mojarra that has this: @Override public boolean containsKey(Object key) { System.out.println("debug: edburns: containsKey(" + key + "): " + request.getParameter(key.toString())); return (request.getParameter(key.toString()) != null); }
          Hide
          kchung added a comment -

          Multipart is not properly scanned, if getParmeter() is called before getParts() is called. Here is the diff for fixing this.

          misto:web-core%svn diff
          Index: src/main/java/org/apache/catalina/fileupload/Multipart.java
          ===================================================================
          — src/main/java/org/apache/catalina/fileupload/Multipart.java (revision 51512)+++ src/main/java/org/apache/catalina/fileupload/Multipart.java (working copy)
          @@ -57,6 +57,8 @@
          import java.util.Collections;
          import java.util.List;
          import java.util.Locale;
          +import java.util.logging.Level;
          +import java.util.logging.Logger;

          import com.sun.grizzly.util.http.Parameters;

          @@ -75,6 +77,9 @@
          private ArrayList<Part> parts;
          private List<Part> unmodifiableParts;

          + private static final Logger log =
          + Logger.getLogger(Multipart.class.getName());
          +
          public Multipart(HttpServletRequest request, Parameters parameters,
          String location, long maxFileSize, long maxRequestSize,
          int fileSizeThreshold)

          { @@ -96,6 +101,14 @@ }

          }

          + public void init() {
          + try

          { + initParts(); + }

          catch (Exception ex)

          { + log.severe("Error in multipart initialization."); + }

          + }
          +
          public String getLocation()

          { return location; }

          Index: src/main/java/org/apache/catalina/connector/Request.java
          ===================================================================
          — src/main/java/org/apache/catalina/connector/Request.java (revision 51512)+++ src/main/java/org/apache/catalina/connector/Request.java (working copy)
          @@ -3148,7 +3148,7 @@
          contentType = contentType.trim();
          }
          if ("multipart/form-data".equals(contentType))

          { - getMultipart(); + getMultipart().init(); }

          if (!("application/x-www-form-urlencoded".equals(contentType))) {
          return;

          Show
          kchung added a comment - Multipart is not properly scanned, if getParmeter() is called before getParts() is called. Here is the diff for fixing this. misto:web-core%svn diff Index: src/main/java/org/apache/catalina/fileupload/Multipart.java =================================================================== — src/main/java/org/apache/catalina/fileupload/Multipart.java (revision 51512)+++ src/main/java/org/apache/catalina/fileupload/Multipart.java (working copy) @@ -57,6 +57,8 @@ import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; import com.sun.grizzly.util.http.Parameters; @@ -75,6 +77,9 @@ private ArrayList<Part> parts; private List<Part> unmodifiableParts; + private static final Logger log = + Logger.getLogger(Multipart.class.getName()); + public Multipart(HttpServletRequest request, Parameters parameters, String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold) { @@ -96,6 +101,14 @@ } } + public void init() { + try { + initParts(); + } catch (Exception ex) { + log.severe("Error in multipart initialization."); + } + } + public String getLocation() { return location; } Index: src/main/java/org/apache/catalina/connector/Request.java =================================================================== — src/main/java/org/apache/catalina/connector/Request.java (revision 51512)+++ src/main/java/org/apache/catalina/connector/Request.java (working copy) @@ -3148,7 +3148,7 @@ contentType = contentType.trim(); } if ("multipart/form-data".equals(contentType)) { - getMultipart(); + getMultipart().init(); } if (!("application/x-www-form-urlencoded".equals(contentType))) { return;
          Hide
          kchung added a comment -

          fix

          Show
          kchung added a comment - fix
          Hide
          Joe Di Pol added a comment -

          Info from kchung:

          • What is the impact on the customer of the bug?

          Only for users using fileupload feature in servlet 3.0. But this fixes an important feature in fileupload.

          • What is the cost/risk of fixing the bug?

          Cost and risk minimal. Only affects two files relating to file upload.

          • Is there an impact on documentation or message strings?

          No.

          • Which tests should QA (re)run to verify the fix did not destabilize GlassFish?

          Run the test case attached to the issue tracker.

          • Which is the targeted build of 3.1.2 for this fix?

          B15.

          Show
          Joe Di Pol added a comment - Info from kchung: What is the impact on the customer of the bug? Only for users using fileupload feature in servlet 3.0. But this fixes an important feature in fileupload. What is the cost/risk of fixing the bug? Cost and risk minimal. Only affects two files relating to file upload. Is there an impact on documentation or message strings? No. Which tests should QA (re)run to verify the fix did not destabilize GlassFish? Run the test case attached to the issue tracker. Which is the targeted build of 3.1.2 for this fix? B15.
          Hide
          kchung added a comment -

          Fixed

          Show
          kchung added a comment - Fixed

            People

            • Assignee:
              kchung
              Reporter:
              dened
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: