We are using Tomcat 5.5 and have a servlet that writes the HTTP response to a ServletOutputStream. Occasionally, a calling application will keep the HTTP connection alive but fail to read the complete HTTP response, effectively blocking the thread that is doing the writing. This in turn blocks our application as this thread is holding on to some critical locks. Is there some way we can set a timeout on this OutputStream (or configure Tomcat to do so) so that it doesn't block forever? We are thinking there should be something somewhat analogous to URLConnection.setReadTimeout(int).
Our code is calling HttpServletResponse.getOutputStream() to get the OutputStream to write to, and here is the a stack trace after we call flush() on this object. "sys_txgc" daemon prio=2 tid=0x079f5000 nid=0x1a3c runnable [0x080df000..0x080dfc94] java.lang.Thread.State: RUNNABLE at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(Unknown Source) at java.net.SocketOutputStream.write(Unknown Source) at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOut putBuffer.java:746) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433) at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer .java:304) at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:991 ) at org.apache.coyote.Response.action(Response.java:182) at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:322 ) at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:293) at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStrea m.java:97) Any thoughts or help is appreciated. Thanks, Gary