Mantis - Resin
Viewing Issue Advanced Details
4431 minor always 03-09-11 20:10 04-06-11 16:41
closed 4.0.15  
none 4.0.17  
0004431: Including a query string in resin:Forward's target results in duplicated request parameters
Say I include the following in my web.xml:

    <resin:Forward regexp="^/foo$" target="/bar?a=1" />

And I define the following servlet:

    public class BarServlet extends HttpServlet
      protected void doGet(HttpServletRequest request,
                           HttpServletResponse response)
          throws ServletException, IOException

Then I make a request to this URL:


I see an output of "[2, 1, 2]" rather than the expected "[1, 2]". It seems that any parameters I define in the request are put into the parameter map twice.
I notice that in my BarServlet example, the following is true:

    request.getQueryString(); // Returns "a=1&a=2".
        RequestDispatcher.FORWARD_QUERY_STRING); // Returns "a=2".
    request.getParameterValues("a"); // Appears to be a combination of the
                                     // two query strings.

That request.getQueryString() is the combination of the one in my resin:Forward rule and in the actual request is different from the behavior of a raw RequestDispatcher.forward call. In that case, request.getQueryString() would be simply "a=1".

I have worked around this in my application by extending the com.caucho.rewrite.Forward class, and overriding the rewriteTarget method like so:

    protected String rewriteTarget(Matcher matcher,
                                   String uri,
                                   String queryString)
      return super.rewriteTarget(matcher, uri, null);

However, I'm guessing that's not the proper solution.

04-06-11 16:41