Meaningless Drivel is fun!
The moose likes Servlets and the fly likes Interruption in servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Interruption in servlets " Watch "Interruption in servlets " New topic

Interruption in servlets

sriram sundararajan
Ranch Hand

Joined: Apr 08, 2003
Posts: 43
when the servlet is executing half the way through, if am clicking the stop button in the browser what will happen inside the servlet and in the server. Which will handle this scenario a servlet or a server.
if i want to handle in my servlet, what should i do then?
Monde Hans

Joined: Jun 26, 2003
Posts: 7
The event is not sent down to the server. The browser just stops. While the thread is still busy processing.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

The sequence of action is:
1. User (browser) sends a URI request to the server. Browser waits for results. The STOP button is enabled.
2. Server decodes URI and determines the action to take. For an HTML page, this is just a matter of locating the file that corresponds to that URL and copying its contents back to the client. For servlets, the servlet dispatcher locates the appropriate servlet and passes the request to that servlet.
3. Servlet executes. Output is placed on the return output stream and transmitted back to the client.
4. When all data has been received, the client displays it (often this is done on-the-fly) and the browser unlocks for another request (the STOP button is disabled).
If you click the STOP button, it unlocks the browser and causes the returning data from the servlet to be discarded. However, if you look at the servlet API, you'll notice that there's no such thing as an HTTP STOP request handler. It is a totally non-interactive process. Once the servlet starts, it's going to run to completion.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Interruption in servlets
It's not a secret anymore!