Proper termination of applet-servlet communication

My client, represented by a java applet, is communicating with a servlet. When the webbrowser is closed, the servlet still has to do some cleaning up.

By closing the browser the destroy Method of the applet is invoked, but doesn't wait for a confirming success message from the servlet.

The servlet runs into the following exception :

- ContextManager: SocketException reading request, ignored - java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read

at java.net.SocketInputStream.socketRead(Native Method) .......

Is there any special "How To" about this topic? Neither the servlet nor the applet tutorial gives any information or hint about this problem.

Can I delay the shut down of the IE until the servlet finished ?

I'm using "IE5.5" with "Java 1.3.0 Plug in" in a "Apache Tomcat" environment.

Every idea is appreciated.

[933 byte] By [zimbo2000] at [2007-9-26 3:14:47]
# 1

Well, the obvious response is that the servlet already knows the applet is going away because of the exception - is there some vital piece of information that the servlet needs to properly cleanup? You said destroy was called, but no time was given to cleanup, what does that mean? Is the thread being terminated in destroy? Does the blocking read fail?

Many questions... Too many questions.

smiths at 2007-6-29 11:25:26 > top of Java-index,Core,Core APIs...
# 2

you can not delay the closing of the IE at all, for sure.

but it seems a little weird that the destroy method executes when the connection with the browser is closed. the servlets destroy method supposed to execute when period time passed and nobody request that servlet and that method get this servlet out of the server memory.

try to overriding the destroy method and print somthing to the log in it, and see when it prints your output.

amitmasl at 2007-6-29 11:25:26 > top of Java-index,Core,Core APIs...
# 3
Java-Plugin runs as a in-process MicroSoft COM object inside IE. IE seems to exit without waiting for the JVM COM object at all, there is no way to let the applet send the last farewell message.
yilin at 2007-6-29 11:25:26 > top of Java-index,Core,Core APIs...