I am new to Programming
I searched a lot in online but no one could satisfy my requirement.Here I want to delate data from database when user close the browser window.
Here i found one solution in stack overflow
public class YourHttpSessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent event) {
//put row in the database
}
public void sessionDestroyed(HttpSessionEvent event) {
//delete the row from database
System.out.println("entered in to listener class");
}
}
and I add in web.xml these lines
<listener>
<listener-class>YourHttpSessionListener</listener-class>
</listener>
Here i don't use any ajax call or some else.But here the sessionDestroyed () is not called when closing the browser.Here i didn't create any sessions.