1 Reply Latest reply on Jul 25, 2003 12:23 AM by tsangcn

    jboss-jetty behaviour in Query Strings in Request Dispatcher

    tsangcn Newbie

      I recently discovered the following behavior of Jetty

      Senerio:
      -------
      Servlet (or JSP) s1 forwards to servlet (or JSP) s2

      String path = "/s1?aa=data2";
      RequestDispatcher rd = context.getRequestDispatcher(path);
      rd.forward(request, response);

      s1 already have a request parameter aa=data1

      Test 1: Jboss 3.2.1 and before:
      ------------------------------
      In s2: request.getParameter() returns "data2"
      request.getParameterValues() returns { "data2" }

      Test 2: JBoss 3.2.1 (with jboss-jetty.sar patch dated 3 june 2003) and JBoss3.2.2RC1:
      --------------------------
      In s2: request.getParameter() returns "data2"
      request.getParameterValues() returns { "data1", "data2" }

      Test 3: JBoss-2.4.10_Tomcat-3.2.3:
      -------------------------
      In s2: request.getParameter() returns "data2"
      request.getParameterValues() returns { "data2", "data1" }


      The result of Test 2 corrupt my application. The I read through the Servlet Spec.


      Servlet 2.3 SRV.4.1 HTTP Protocol Parameters (page 31)
      -------------------
      The getParameterValues method returns an array of String objects containing all the parameter values associated with a parameter name. The value returned from the getParameter method must be the first value in the array of String objects returned by getParameterValues.

      Servlet 2.3 SRV.8.1.1 Query Strings in Request Dispatcher Paths (page 56)
      ---------------------
      The ServletContext and ServletRequest methods that create RequestDispatcher objets using path information allow the optional attachment of query string information to the path. For example, a Developer may obtain a RequestDispatcher by using the following code:

      String path = "/raisons.jsp?orderno=5";
      RequestDispatcher rd = context.getRequestDispatcher(path);
      rd.include(request, response);

      Parameters specified in the query string used to create the RequestDispatcher take precedence over other parameters of the same name passed to the included servlet.

      Servlet 2.2 8.1.1
      -------------------
      The contents of the query string are added to the parameter set that the included servlet has access to. The parameters are ordered so that any parameters specified in the query string used to create the RequestDispatcher take precedence..

      So from Test1, JBoss3.2.1 (without jboss-jetty.sar patch) and before violate Servlet 2.2 spec (8.1.1).

      So from Test2, JBoss3.2.1 (with jboss-jetty.sar patch) and JBoss3.2.2RC1 conforms to 8.1.1 but violates 4.1 (The value returned from the getParameter method must be the first value in the array of String objects returned by getParameterValues.)

      The result of Test 3 (using Tomcat) conforms to the spec.


      I have attached a JSP for you to test.

      Anyone aware of this and make corrections to jboss-jetty?

      Thanks
      CN