You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Les Parkin <le...@uk.lionbioscience.com> on 2004/09/13 11:51:48 UTC

Detecting The Stop Button

Hi,

I am working on an application that allows users to run database queries 
from a web browser (we are currently using Tomcat 5.0.25). A problem 
arises when a user starts a new query and then decides that they want to 
cancel it by hitting the browser "stop" button. After a lot of reading 
on this already, I appreciate that it is not possible for Tomcat to be 
notified that this has occurred, since no event is generated by the 
browser that Tomcat can detect. The solution I attempted was to start a 
background "pinger" thread in Tomcat which periodically writes back to 
the browser as the query is running. The theory was that if the user 
hits the "stop" button then I would get an IOException since the socket 
connection has been broken. In practice this does not happen, the pinger 
thread continues to write output without any exception or error 
occurring, and it is as if this output is being lost in a black hole 
somewhere! (the browser does not receive any more output after the stop 
button has been pressed, as expected).
Has anybody got any suggestions as to how I can get this to work, or a 
more general approach to solving the "stop" button problem?

Many Thanks!
Les.





---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Detecting The Stop Button

Posted by Andoni List <an...@eurokom.ie>.
This is certainly not an easy thing to do, you could try to use JavaScript
to continuously generate requests to the server every 5 seconds until the
results are ready and then they are returned instead of the "waiting"
screen. Then you would have to tell the servlet to expect requests every 5
(maybe a little more to allow for synchronization issues) seconds and when
it doesn't get one to act on this fact by shutting down the process.

When you see the airline sites where they are validating Visa card numbers
in real time and they simply put up a page which says "Please allow up to
60seconds for this process to complete. Do not hit back, stop or refresh
until this process completes" you can tell that any kind of detection is
tricky because if it wasn't they'd implement it.

What we have done on our company's site where we poll servers around the
world for delay times we return an intermediary page which in turn calls the
results page. This intermediary page has the "Please wait..." message on it.
One useful tip I can give you is that when we tried to put an animated GIF
on this page to keep the customer focused, it failed because the page did an
immediate request and the GIF stopped as soon as the request went out. What
does work though is a small flash animation which keeps running even though
another page has been requested.

Anyway that's my 2c worth, hope you can take something from it.

Later,
Andoni.


----- Original Message ----- 
From: "Les Parkin" <le...@uk.lionbioscience.com>
To: <to...@jakarta.apache.org>
Sent: Monday, September 13, 2004 10:51 AM
Subject: Detecting The Stop Button


> Hi,
>
> I am working on an application that allows users to run database queries
> from a web browser (we are currently using Tomcat 5.0.25). A problem
> arises when a user starts a new query and then decides that they want to
> cancel it by hitting the browser "stop" button. After a lot of reading
> on this already, I appreciate that it is not possible for Tomcat to be
> notified that this has occurred, since no event is generated by the
> browser that Tomcat can detect. The solution I attempted was to start a
> background "pinger" thread in Tomcat which periodically writes back to
> the browser as the query is running. The theory was that if the user
> hits the "stop" button then I would get an IOException since the socket
> connection has been broken. In practice this does not happen, the pinger
> thread continues to write output without any exception or error
> occurring, and it is as if this output is being lost in a black hole
> somewhere! (the browser does not receive any more output after the stop
> button has been pressed, as expected).
> Has anybody got any suggestions as to how I can get this to work, or a
> more general approach to solving the "stop" button problem?
>
> Many Thanks!
> Les.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Detecting The Stop Button

Posted by Thomas Kellerer <sp...@gmx.net>.
On 13.09.2004 11:51 Les Parkin wrote:

> Hi,
> 
> I am working on an application that allows users to run database queries
> from a web browser (we are currently using Tomcat 5.0.25). A problem
> arises when a user starts a new query and then decides that they want to
> cancel it by hitting the browser "stop" button. After a lot of reading
> on this already, I appreciate that it is not possible for Tomcat to be
> notified that this has occurred, since no event is generated by the
> browser that Tomcat can detect. 
> [...]
> Has anybody got any suggestions as to how I can get this to work, or a
> more general approach to solving the "stop" button problem?
> 

You could put a "Cancel query" button on the form itself, which then notifies
tomcat. You then need to identify the running query in the session and kill it.

But I guess there is no way of doing this with the Browser's stop button.

Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org