Some of the tasks my stateful server performs take a while to complete, and
I want to respond gracefully if a user has killed their browser before I've
gotten around to sending a response.  To set the stage, I use an
architecture that has all user responses arriving at a single servlet
(unoriginally  named FrontController, ala Alur, Crupi and Malks), then after
some processing the output is sent out via a collection of JSPs.  Currently,
if the browser exits before I send something to it, I get an exception that
looks like this:

java.net.SocketException: Connection reset by peer: socket write error
        at
org.apache.tomcat.core.BufferedServletOutputStream.reallyFlush(BufferedServl
etOutputStream.java:234)
        at org.apache.tomcat.core.ResponseImpl.finish(ResponseImpl.java:206)
        at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
.java:215)
        at alo.FrontController.dispatchme(FrontController.java:339)
        at alo.FrontController.processRequest(FrontController.java:315)
        at alo.FrontController.doPost(FrontController.java:65)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
        at org.apache.tomcat.core.Handler.service(Handler.java:286)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
        at java.lang.Thread.run(Thread.java:484) 

What I'd like to do is to run some test to see if the browser is open, and
if it isn't then save the output for display the next time the user returns.
Of course, this solution can fail too, so even better would be to fail over
in case of exception and save the output.  I would go ahead and save
everything on every request, but my examination of the mailing archives
makes it seem that getting JSP output is difficult or impossible.  Does
anyone have a better solution to my problem, so that I don't waste
processing time only to send information off into the ether?

Thanks,
Ben  

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to