You can use jQuery to solve the problem of closing the browser,
JQuery will be
$(window).on('beforeunload', function(){ return 'Are you sure you want to leave?'; }); $(window).on('unload', function(){ //alert("unload"); $.ajax({ type: "POST", url: "Logout.html", //data: "message=" + message, dataType: "html", success: function(response) { }, error: function(e) { //alert('Error: ' + e); } }); });
In the spring controller ,
@RequestMapping(value="Logout.html",method=RequestMethod.POST) public @ResponseBody String logout(HttpSession session){ System.out.println("Request Logout");
In web.xml add this. If you used HttpSessionEventPublisher to catch the session kill event,
<listener> <listener-class> org.springframework.security.web.session.HttpSessionEventPublisher </listener-class> </listener>
Hope this helps.
Human being
source share