• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does a servlet continue processing after I hit Stop?

 
Franco Finstad
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic