Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004431 [Resin] minor always 03-09-11 20:10 04-06-11 16:41
Reporter mhixson View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 4.0.15
Summary 0004431: Including a query string in resin:Forward's target results in duplicated request parameters
Description Say I include the following in my web.xml:

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

And I define the following servlet:

    @WebServlet(urlPatterns="/bar")
    public class BarServlet extends HttpServlet
    {
      @Override
      protected void doGet(HttpServletRequest request,
                           HttpServletResponse response)
          throws ServletException, IOException
      {
        response.getWriter().write(
            Arrays.toString(
                request.getParameterValues("a")));
      }
    }

Then I make a request to this URL:

    /foo?a=2

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.
Additional Information I notice that in my BarServlet example, the following is true:

    request.getQueryString(); // Returns "a=1&a=2".
    
    request.getAttribute(
        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:

    @Override
    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.
Attached Files

- Relationships

- Notes
(0005173)
ferg
04-06-11 16:41

server/1knb
 

- Issue History
Date Modified Username Field Change
03-09-11 20:10 mhixson New Issue
03-09-11 20:11 mhixson Issue Monitored: mhixson
04-06-11 16:41 ferg Note Added: 0005173
04-06-11 16:41 ferg Assigned To  => ferg
04-06-11 16:41 ferg Status new => closed
04-06-11 16:41 ferg Resolution open => fixed
04-06-11 16:41 ferg Fixed in Version  => 4.0.17


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
30 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker