Posts

Showing posts from February, 2014

Http Session creation and Destroy events...

HttpSession is one of the commonly used way of identifying users across multiple requests between clients and servers. In order to provide various services such as authentication, authorization etc. for users and to store user information, logging and audit purposes, it is required to keep track of newly created sessions, active sessions and session destroy events. HttpSessionListener interface in servlet API provides methods to receive session events for its implementation classes published by the servlet container.
Lets look at a sample class 'WebSessionListener' which implements "HttpSessionListener" interface.
import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class WebSessionListener implements HttpSessionListener { //Notification that a session was created. @Override public void sessionCreated(HttpSessionEvent httpSessionCreatedEvent) { } //Notification that a session is about to b…