stoping doGet/dopost in java servlets ?

Posted by bosso on Stack Overflow See other posts from Stack Overflow or by bosso
Published on 2010-03-14T23:28:59Z Indexed on 2010/03/14 23:35 UTC
Read the original article Hit count: 579

Filed under:
|
|
|

Hello everyone,

I've been playing with Java Servlets and Ajax a bit, and I've got a situation on which I would really appreciate advice.

Let's say I have HTML page with a start and stop buttons, and as a result of clicking start button,
overridden doGet (or doPost) method on a servlet is invoked which computes something that takes a long time to complete. (e.g. a giant loop, or even Infinite loop, doesn't matter, I'm interested in concepts here).

So, I'm asking you:

1.What would be my options to kill / shut down / halt / exit doGet method whan I hit stop button on a web page? Do I use threading here, or there is simpler way? I take it that using System exit is not a very good idea, right? ;)

2.So, let's say I implement code for stopping doGet method. What would happen If I hit start on one browser(e.g.IE), and while this long computation takes place open new tab or other browser(e.g.Firefox) and open same url and hit stop? Would that stop my original computation? Is there any easy way to avoid this?

I know that questions are a bit off, as I'm just starting with server-side of things. :)

Any suggestions would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about java