jump to navigation

Servlet Listeners August 24, 2005

Posted by Coolguy in Servlets/Jsp.
  • Attribute added,removed or replaced: ServletContextAttributeListener
  • Tracking active sessions: HttpSessionListener
  • Log each request: ServletRequestListener
  • Request attribute added,removed or replaced: ServletRequestAttributeListener
  • Attributes added to session: HttpSessionBindingListener
  • Session attribute added,removed or replaced: HttpSessionAttributeListener
  • Context created or destroyed: ServletContextListener
  • Attributes notified when the session is migrating to another JVM:HttpSessionActivationListener


  • This class knows when any type of attribute has been added,removed or replaced in a session


  • Attribute itself can find out when it has been added to or removed from a session
  • E.g:
    import javax.servlet.http.*;public class Dog implements HttpSessionBindingListener
    private String breed;

    public Dog(String breed)
    public String getBreed()
    return breed;
    public void valueBound(HttpSessionBindingEvent arg0)
    // TODO Auto-generated method stub
    public void valueUnbound(HttpSessionBindingEvent arg0)
    // TODO Auto-generated method stub



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: