I have a JSP WebApplication created. Sessions are used for some features which needs to be destroyed after closing the browser. While I am testing it in my browser (Mozilla), the session does not destroy . Please Help!
1 Answer
You can create a service or jsp in which you can invalidate (destroy) the session.
request.getSession().invalidate() You can send a call to this service on browser window close event through javascript like
// window.onclose is Not available with Firefox 2 or Safari window.onclose = function(event){ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","<your-service-url>",false); xmlhttp.send(); }