This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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
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
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