tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 14436] New: - RequestDispatcher Drops Query String
Date Mon, 11 Nov 2002 02:42:24 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14436>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14436

RequestDispatcher Drops Query String

           Summary: RequestDispatcher Drops Query String
           Product: Tomcat 4
           Version: 4.1.14
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Unknown
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: tony@absolutejava.com


Hello,

I'm using TC 4.1.12 on Win 2k. I'm using the TC Coyote Connector.

I've checked the Servlet v2.3 spec and the behavior I'm seeing in TC seems to 
go against the spec. In general, the problem is that the original query string 
is not properly aggregated when a servlet is invoked using a RequestDispatcher 
where and the target servlet has its own query string. Here's an example:

I have a servlet called "servletA". Let's say "servletA" is invoked from a 
browser with this URL:

http://localhost/tst/ServletA?x=1

Within "servletA" we create a RequestDispatcher for "servletB" and then forward 
to "servletB" like this:

RequestDispatcher rd = request.getRequestDispatcher("servletB");
rd.forward(request, response);

In "servletB", a call to "request.getQueryString()" returns the string "x=1". 
In other words, "servletB" is able to "see" the query string used to 
invoke "servletA". Okay, so far, so good.

Now, here's the problem: If "servletA" appends a query string to "servletB" 
when creating the RequestDispatcher like this:

RequestDispatcher rd = request.getRequestDispatcher("servletB?z=1");

"servletB" will only see the query string, "z=1", it will *no longer* see 
the "x=1" query string.

What I *expect* to see in "servletB" is a query string "x=1&z=1" -- i.e., 
*both* query strings.

Let me quote from SRV.8.1.1 (Servlet 2.3): "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."

In my example, the parameter names are *not* the same ("x" and "z") so the "z" 
parameter should not take precedence over "x". Also, the quote above refers to 
the "included servlet". I believe this generically refers to forwarded servlets 
as well. The example in the spec just happens to be using include() rather than 
forward().

Finally, I would like to mention what happens if you use the 
RequestDispatcher.include() method rather than forward(). Using my example 
above, if you change forward() to include(), "servletB" will only see the "x=1" 
query string. It will *never* see the "z=1".

One last quote from the servlet spec (SRV.8.4.1): "The request dispatching 
mechanism is responsible for aggregating query string parameters when 
forwarding or including responses."

So, can you confirm that this is a bug?

Thanks very much...

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message