javascript - ajax - to close session on closing browser in JAVA
===

In my web application 

1.1I have to close the session when the user abruptly close the browser.

1.2. When the user tries 'open in a new tab' - The user should be forwarded to the 'login page' in the new tab

I am planning to use JAVASCRIPT and AJAX to implement this in JSPX.

Can any one share any sample code to implement he above as I am new to javascript/ajax? 