You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael Wentzel <Mi...@aswethink.com> on 2001/04/10 17:55:25 UTC

RE: What happens executing request thread when browser terminates connection?

> I'm using Tomcat 3.2.1 to run a servlet that can, depending on the
processing that needs to be performed, take a 
> long time to send the response back to the browser (it hits off back end
systems to perform different tasks 
> depending on request params, some of which are quite lengthy). I have
Tomcat configured to use the 
> PoolTCPConnector, so, as I understand, a single instance of the servlet is
instantiated, and then each subsequent > request gets executed in a new
thread as allocated by a thread pool that Tomcat maintains. 
> My question is - what happens to one of these executing threads if the
user clicks stop on the browser before the > servlet has sent any response,
or the user gets impatient waiting, and clicks on the same (or another)
link, 
> thereby cancelling the original request?? 

The thread will continue as necessary.  We had this same problem when using
a servlet to gen pdf's.  If the user
clicks stop, back, or navigates elsewhere before completion Tomcat has no
way of knowing that the previous request should be stopped and lets the
servlet continue running.  I'm sure you could handle this by adding a layer
to your page logic and a server-side only registration servlet that gets
registered for every new thread and then the page logic would check for an
existing thread and kill if necessary.  This would raise other problems like
if a user has two browser windows running under the same session though.
You'd probably have to key off of several values(at least two - like page
and sessionid) to get unique hash values that can be reacquired as
necessary.  Just an idea.



--- 
Michael Wentzel 
Software Developer 
Software As We Think - http://www.aswethink.com