First of all, you need to catch an event when the browser is closed.
You can try under the code snippet in jsp to get into the js function that will call the ajax function to hit the server side component. Then simply use the session API to cancel the session and add code to remove the record from the table.
window.onbeforeunload = WindowClose; function WindowClose() {
Or use
<body onunload="WindowClose(); >
In server side code use
HttpSession session = request.getsession (); session.setMaxInactiveInterval (0); // or session.invalidate ();
A good approach is to determine the default session timeout value in the web.xml file so that the browser crashes, the sessions are invalid after a specified period of time.
<session-config> <session-timeout>30</session-timeout> </session-config>
source share