Hi,
I am given an assignment to solve following problem:
We have a website and our clients can login
in and do there works.Sometimes we have to
shutdown the server and we need let the clients
who are still using the site get the warning
message.
My solution is to write an
applet and embed it
in the first login page. This applet will create
a new
thread which can send request to the server
in a no-end-loop(every 10 minutes sleep),and if it
got the warning response, then it will show a
popup window with message like "The server will
shutdown at 3PM,please save your work before 3PM".
I start the thread in Applet.start() method,
and clear it to NULL in Applet.destroy() method,
do thing in the stop() method so that even the
user goes to the other pages,the thread is still
working.
But when I
test the applet with different browsers,it behave differently:
With Sun Hotjava, this approach works.The only
problem is that the thread can only be stopped
when the browser is closed. That is,the Applet.destroy() method is not called until the
user close the browser(this is not perfect,but
we can accept since it works).
So,the cycle is like following:
enter into the login page -- call init(),start().
Leave the login page and go to other pages in the
same site --- call Applet.stop() method.
Leave the site --- call Applet.stop() method.
Close browser --- call Applet.destroy() method.
With IE5,in some computer, it works in the same
way as the Hotjava.But,in some other computer,
once the user leaves the Login page, the Applet's
destroy() method is called.
So the problem is that we are not sure when the
Applet's destroy() method is called.If it is
called too early,then the approach fails.
The browser at client side is uncertain,we only
know it is IE4.0 or above.
Any advice is apperiated!