tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: How can Servlet detect lost of connection to client?
Date Sun, 28 Sep 2008 08:36:31 GMT
If (and only if) it is really worth the effort, there might be a way to 
do this.
I would not know the details of how to achieve this with Tomcat, but I 
remember writing something like that under Apache and perl.
Consider thus what follows as a very rough approximation, and no more 
than an hint.

It would go like this :

At the beginning of your servlet processing, you write the HTTP response 
headers to the client, and a first response part saying "please wait...".
Then your servlet starts processing, and at given intermediate points in 
this processing, it writes a further "please wait some more..." to the 
output.
If when writing it finds a closed socket, it knows the client has gone.
Otherwise, it continues processing and sends the real response at the end.

The above is predicated on my suspicion (nothing sure here), that Tomcat 
can/will regularly flush the servlet output to the browser, even before 
the servlet output is complete (or that the servlet can itself "flush" 
the buffer).

In my case, the purpose was not to save processing time on the server 
side.  Rather, it was to avoid that the user on the client side would be 
faced with a long response time without visual feedback, and would start 
clicking all over the place, as users are wont to do.


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


Mime
View raw message