tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: reading html-form parameters within servlet filter on tomcat 4.0.3
Date Tue, 02 Apr 2002 16:42:26 GMT

On Tue, 2 Apr 2002, Alexander Thomas wrote:

> Date: Tue, 02 Apr 2002 05:57:11 +0200
> From: Alexander Thomas <>
> Reply-To: Tomcat Users List <>
> To:
> Subject: reading html-form parameters within servlet filter on tomcat
>     4.0.3
> Hi gents,
> I am trying to set up a servlet filter which uses the
> HttpServletRequest.getParameterNames() and
> HttpServletRequest.getParameter(...)
> methods.
> However, the terminating servlet in the filterchain has to be allowed
> access to these methods as well!
> Currently, I am confronted with an exception indicating that it is not
> allowed to get the ServletInputStream two times.
> I suppose I have to set up appropriate HttpServletRequestWrappers.
> However I am not quiet sure how that is supposed to be done in this
> special case.

It is not going to be possible to read the "real" input stream more than
once.  Note that this would occur on a POST even without filters, if you
tried to call getParameter(...) followed by getInputStream() on the same

> Also interessting to note is the fact that tomcat 4.0.3 seems to ignore
> the contents of an offered HttpServletRequestWrapper object while
> evaluating the getParameter method in the terminating servlet. I would
> like do clarify if this behaviour is on purpose (In accordance to the
> spevlet 2.3 spec).

The only way to implement this is going to be somewhat memory-expensive --
you have to design a wrapper that buffers the data the first time that
getInputStream() or getReader() is called, and then replays it the second
time.  Note that Tomcat is going to use getReader() -- the POST data is
assumed to be in characters formats -- so that is the one you will
actually need to replace.

> Any help or hint would be highly appreciated,
> Regards,
> Alexander Thomas


To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message