tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arvind Srinivasan" <>
Subject TC4: qn about requestdispatcher forwards and input streams
Date Wed, 17 Apr 2002 05:20:14 GMT

I'd appreciate it if someone can clarify whether the following is a bug in
TC4 or not.

I have a servlet whose doPost() implementation simply gets hold of a
requestdispatcher and invokes forward() on it. The form that is posted
contains a couple of name/value parameters. The forwarded-to servlet runs
into an error when it tries to read data from the input stream of the
request. The error is that the input stream has already been closed.

o.a.c.core.ApplicationDispatcher.forward() invokes its wrapRequest() method
which in turn ends up invoking ApplicationHttpRequest.setRequest() which
reads the parameters (request.getParameterMap()) from the input stream and
closes the input stream.

The servlet spec says the following about POST data parameters.
SRV.4.1.1 When Parameters Are Available
The following are the conditions that must be met before post form data will
be populated to the parameter set:
1. The request is an HTTP or HTTPS request.
2. The HTTP method is POST
3. The content type is application/x-www-form-urlencoded
4. The servlet has made an initial call of any of the getParameter family of
on the request object.
If the conditions are not met and the post form data is not included in the
parameter set, the post data must still be available to the servlet via the
object’s input stream. If the conditions are met, post form data will no
longer be
available for reading directly from the request object’s input stream.

If my understanding is right, condition #4 is not met in the
ApplicationDispatcher.forward() codepath,  so the parameters/data should not
have been read from the input stream. (I read the request dispatcher section
of the spec and it only talked about query string parameters and doesn't say
what should be done to the data on the input stream.)


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message