tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Thomas <>
Subject Re: reading html-form parameters within servlet filter on tomcat 4.0.3
Date Tue, 02 Apr 2002 22:17:55 GMT
Dear Craig,

thanks for your swift reply! As you suggested I tried to foist the 
servlet a new instatnce of the BufferedReader class.
The codesection in the doFilter method of my filter class looks like this:

HttpServletRequestWrapper httpServletRequestWrapper = new 
HttpServletRequestWrapper() {
        public BufferedReader getReader() {
                return new BufferedReader(new 


chain.doFilter(httpServletRequestWrapper, response)

However, this approach does not have an impact on the parameters present 
in the servlet!!

I am not very familiar with the debug option in catalina. Nevertheless, 
I used it and came to the conclusion that the servlet actually does not 
use the HttpServletRequest object while evaluating the getParameter method.

Can you confir that?


Alexander Thomas

Craig R. McClanahan wrote:

>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 <>
>>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
>>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,
>>Alexander Thomas
>To unsubscribe:   <>
>For additional commands: <>
>Troubles with the list: <>

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

View raw message