You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jess Holle <je...@ptc.com> on 2011/05/17 23:38:23 UTC

General Async Request Question

I'm trying to get up to speed with the Servlet 3.0 specification -- 
specifically asynchronous requests vs. all my existing filters, etc.

I have an existing response compression filter.  Yes, I know Tomcat's 
HTTP connector can do this, but our filter has some special features, 
works with the AJP connector (which we use), and works with other 
servlet engines besides Tomcat.

Part of the existing logic is:

     final GzippingResponse  gzippingResponse = new GzippingResponse( origHttpRequest, origHttpResponse );
     try
     {
       filterChain.doFilter( origRequest, gzippingResponse );
       gzippingResponse.finish();
     }
     finally
     {
       gzippingResponse.end();
     }

where finish() calls ServletResponse.flushBuffer() and 
GZIPOutputStream.finish() and end() calls Deflator.end() to do timely 
release of resources.

My issue here is how can I ensure that gzippingResponse.finish() is 
called prior to the response stream being closed but after all calls 
writes to the response?  AsyncContext.complete() sounds like it closes 
the output streams/sockets and *then* calls the completion listeners.  
Is this simply a misunderstanding on my part or is there some other 
means for a filter to interject itself between the final write to a 
response and stream/socket closure?

--
Jess Holle


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