|
I implemented HttpSessionListener interface and there are two methods
sessionDestroyed() and sessionCreated(). Nothing to do with session created.
I just updated database in sessionDestroyed() method, and i will be called by container just before session.invalidate() is called.
and added the listener entry into web.xml file.
There are three chances from where user can be marked as logout.
1. Session timeout by container.
2. User clicks on Logout link
3 User close the browser window.
In First case Listener is called by Container and Database is updated.
In second case i called a servlet that do the session.invalidate() and calles a method to update Database.
In 3rd case : When user closes the browser window i called the same servlet from scripts and updated the Database
If still you have any doubts the please feel free to ask anything.
sanjeev
|