• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Life time of a servlet - very important

 
Subbu Aswathanarayan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i have got a very basic question. i have a servlet which a number of users access. my question is, if a user closes the browser window in the middle of the servlet execution(i mean before the entire servlet is executed) will the servlet be killed instantly or will the servlet get fully executed before it is killed.
i hope my question is clear.
any help would be greatly appreciated.
Subbu
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a normal servlet container, there is only one instance of the servlet object. This object may be used by any number of Threads - one Thread per request. Managing the lifetime of a servlet instance is up to the servlet container.
If a browser closes a connection while the servlet is writing to it, an exception is thrown. If your servlet does not provide for catching the exception, the servlet engine catches it. Other Threads executing other requests are not affected unless your code uses instance variables incorrectly.
Nothing a request can do can kill a servlet unless you made a REALLY big coding mistake, typically when calling non-java functions.
Bill

------------------
author of:
 
Manjunath Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a browser closes a connection while the servlet is writing to it, an exception is thrown...to be more specific
Thu Aug 20 09:53:19 GMT 1998: Servlet failed with Exception
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite(Native Method)
at java.net.SocketOutputStream.write(SocketOutputStream.java, Compiled Code)
at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java, Compiled Code)
......so on and so forth..
mpr
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic