aspose file tools*
The moose likes Servlets and the fly likes Does a servlet continue processing after I hit Stop? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Does a servlet continue processing after I hit Stop?" Watch "Does a servlet continue processing after I hit Stop?" New topic
Author

Does a servlet continue processing after I hit Stop?

Franco Finstad
Greenhorn

Joined: May 02, 2003
Posts: 22
Does a servlet continue processing my request even if I hit the browser Stop button?

For example, servlet that executes a big database search. I hit Search, and the servlet queries the db and starts iterating through the result set -- then I hit Stop. What happens?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
The servlet has no way of knowing that you hit stop, so it will keep on grinding. As far as I know, stop only closes all connections that the browser has opened in trying to build the page display. The servlet will only detect this when it trys to write to the response output stream and hits an IOException. Therefore, your servlet should flush() the output buffer after every write, in order to detect the closed connection as soon as possible.
Bill
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
Does not a flush of the buffer commit the response and prevent any further info from being written?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Executing flush "commits" the response headers, so you can't change them but the connection stays open. If you have a time consuming response generation process, doing some output and calling flush can show your user that some progress is being made.

Bill
michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
What if my servlet query does not use buffer. Will using flush makes any difference. What if I use beans instead. Can I still apply flush to beans ?
Thanks for the answer first.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Your response is buffered by default. I am not sure what you mean by "applying flush to beans". A buffer is associated with an input/output stream.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does a servlet continue processing after I hit Stop?