jasonb wrote:
> 
> Hi Andrea.
> 
> When the client disconnects, and your servlet tries to write to the output
> stream, Tomcat will throw a ClientAbortException (you may have already
> seen
> this):
> 
> http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/connector/ClientAbortException.html
> 
> Tomcat appears to only throw this exception when you either write some
> bytes
> to the output stream or when you flush the output stream, and the client
> already closed its end of the connection.  It appears that you could
> periodically try flushing the output stream and see if doing so throws
> this
> exception. You can flush after writing any number of bytes, including zero
> bytes.  The first time you call flush, it will send the HTTP response
> headers to the client, so you would need to first set the headers before
> flushing.  That sounds difficult for you to do because you're writing an
> image, and one of the headers would be Content-Length, which you probably
> don't know until your image is generated.


We actually don't send the content length out, we used chunked transfer
instead (that is, stream out the result of the png compression as made by
JAI
Image I/O) but unfortunately we cannot do that either, as the protocols
mandates that any error occurring during rendering be returned as XML.

So I actually know the final content type only when the image is fully
rendered,
which is when I start writing out bytes anyways.

Cheers
Andrea

-- 
View this message in context: 
http://www.nabble.com/How-to-check-if-the-client-dropped-the-connection-tp25641481p25651470.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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

Reply via email to