Feb 28th, 2007, 09:47 PM
Help with MultiActionController
I am defining a MultiActionController using the PropertiesMethodNameResolver. My requirement is that I call the method when the browser is closed. I have a bunch of session invalidation methods (session.invalidate()). How can I invoke this method upon closing of the browser( click the cross)
Mar 1st, 2007, 06:46 AM
You can't do this easily. The browser doesn't send any message to the server when it closes. So the server has no direct way of knowing if someone kills the browser.
The server has a session timeout, which means that after some inactivity (eg. 30 mins), the session will close. You can set up a sessionListener to listen for such lifecycle events.
One way to cheat is to have a small iframe or frame, that loads a JSP that refreshes itself (using meta refresh) every 10s or so. Each time the refresh is called, the server should reset a timer. If the timer ever goes, say, 15s without being reset, you might assume that the browser is no longer looking at your page - possibly because it's closed, or maybe because the user is looking elsewhere.