Aloha,

Thanks for the pointer...  I was initially under the impression that
the servlet doGet() method was called *after* returning from my doFilter()
method, but now realize that the servlet doGet() method is indeed called
from "recursively" invoking FilterChain.doFilter() and should be completed
before my doFilter() returns.  It was staring right at me and I couldn't
see it.  Thanks for the tip!

- Glen Nakamura


On Wed, Feb 06, 2002 at 09:12:19PM -0800, Craig R. McClanahan wrote:
> 
> 
> On Wed, 6 Feb 2002, Glen Nakamura wrote:
> 
> > Date: Wed, 6 Feb 2002 18:59:13 -1000
> > From: Glen Nakamura <[EMAIL PROTECTED]>
> > Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: Filters and HttpServletResponse.close();
> >
> > Aloha,
> >
> > When does the HttpServletResponse object get closed if the servlet doGet()
> > method doesn't call HttpServletResponse.close() explicitly?
> > For example, suppose a servlet filter creates a HttpServletResponseWrapper
> > to wrap the initial HttpServletResponse and passes on this new response
> > object down the doFilter() chain.  The servlet doGet() method eventually
> > gets called, but doesn't explicitly call close() of the wrapped
> > response object.  After tomcat returns from the container's invoke() method,
> > it calls finishResponse() which is supposed to flush and close the response
> > object, but isn't this the original response object?  What about the
> > wrapped response object created by the filter?  It appears it never gets
> > closed and is not flushed properly.  I think this explains why I'm not
> > getting any output from my filter when doGet() doesn't explicitly call
> > HttpServletResponse.close().  Did I miss something?
> >
> 
> As you noted, Tomcat calls finishResponse() after the servlet returns.
> However, this is called only on the *original* response that Tomcat
> provided to the servlet -- not to any wrappers that your application has
> created.
> 
> It is your application's responsibility to ensure that anything it has
> buffered in a response wrapper is flushed to the "real" response prior to
> your filter returning from its doFilter() method.
> 
> > - Glen Nakamura
> >
> 
> Craig McClanahan
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to