Tomcat 6.0.29

I've written a response filter for my web app and it seems to work fine
for servlets but not for JSP's.  I

public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain ) throws IOException, ServletException { chain.doFilter(request, new MyResponseWrapper((HttpServletResponse)response));
    }

    private class MyResponseWrapper extends HttpServletResponseWrapper {
        private MyOutputStream myOutputStream;
        private PrintWriter printWriter;

public MyResponseWrapper( HttpServletResponse response ) throws IOException {
            super(response);
            myOutputStream = new MyOutputStream(response);
OutputStreamWriter osw = new OutputStreamWriter(myOutputStream, response.getCharacterEncoding());
            printWriter = new PrintWriter(osw);
        }
        public ServletOutputStream getOutputStream() throws IOException  {
            return myOutputStream;
        }
        public PrintWriter getWriter() throws IOException {
            return printWriter;
        }
    }

MyOutputStream extends ServletOutputStream and wraps the methods in
the stream returned by response.getOutputStream().  The write() routines
do some manipulation of the output and send the modified output to the
wrapped stream.

The problem seems to be that it only calls write(byte[], int, int) once when
it's a JSP. It will get called multiple times for a servlet but just once for the JSP. It's getting called with offset = 0 and len = 8192, and that's about
how much output I get.  My page is always truncated.  Obviously there is
some sort of buffered writer calling my write() routine.  All of the output
methods from ServletOutputStream are overridden and logged, so I know
what is getting called.

Also, flush() gets called at the end for servlets but never gets called for a JSP.

I don't get any exception messages in my log.

Is it something wrong in my config?

<filter>
<display-name>MyFilter</display-name>
<filter-name>MyFilter</filter-name>
<filter-class>com.mycompany.filters.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/servlets/*</url-pattern>
<url-pattern>/jsp/*</url-pattern>
</filter-mapping>

Is there something I need to do in my JSP's?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to