Servlet -- HttpSessionBindingListener interface, HttpSessionBindingEvent class

Source: Internet
Author: User

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;  }}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.