Servlet -- HttpSessionBindingListener interface, HttpSessionBindingEvent class
HttpSessionBindingListener Interface
Definition
Public interface HttpSessionBindingListener
This object is added to the HTTP session. executing this interface will notify you whether any object is bound to this HTTP session or unbound from this HTTP session.
Method
1. valueBound
Public void valueBound (HttpSessionBindingEvent event );
This method is called when an object is bound to a session. When the HttpSession. putValue method is called, The Servlet engine should call this method.
2. valueUnbound
Public void valueUnbound (HttpSessionBindingEventevent );
This method is called when an object is unbound from the session. When the HttpSession. removeValue method is called, The Servlet engine should call this method.
HttpSessionBindingEvent classDefinition
Public class HttpSessionBindingEventextends EventObject
The connection to HttpSessionBindingListener occurs when you hear the situation that the HttpSession was bound and unbound. This may be the result of a session being terminated or deemed invalid. The event source is HttpSession. putValue or HttpSession. removeValue.
Constructor
Public HttpSessionBindingEvent (HttpSession session, String name );
Construct a new HttpSessionBindingEvent using the Session that causes this event and the object name that is bound or unbound.
Method
1. getName
Public String getName ();
Returns the name of the bound or unbound object.
2. getSession
Public HttpSession getSession ();
Returns the name of the bound or unbound session.
package javax.servlet.http;public class HttpSessionBindingEvent extends HttpSessionEvent{ private String name; private Object value; public HttpSessionBindingEvent(HttpSession session, String name) { super(session); this.name = name; } public HttpSessionBindingEvent(HttpSession session, String name, Object value) { super(session); this.name = name; this.value = value; } public HttpSession getSession() { return super.getSession(); } public String getName() { return this.name; } public Object getValue() { return this.value; }}