| Scope | Lifecycle listeners | Attribute change listeners | Register | 
| Application | ServletContextListener | ServletContextAttributeListener | @WebListener | 
| Servlet | HttpServlet | @PostConstruct @PreDestroy | |
| Session | HttpSessionListener | HttpSessionAttributeListener | @WebListener | 
| Request | ServletRequestListener | ServletRequestAttributeListener | @WebListener | 
| Asynchronous Request | AsyncListener | AsyncContext#addListener | 
- Additional Session Listeners:      - HttpSessionBindingListener: Notifies an attribute that it is bound/unbound from the session attribute map
- HttpSessionActivationListener: Notifies an attribute that it is passivated to/activated from persistent storage (session passivation)
 
- WebListeners can also be registered using      - web.xml          <web-app> <listener> <listener-class>org.edu.MyListener</listener-class> </listener> … </web-app>
 
- programmatically using ServletContext#addListener from a ServletContextListener
 
 
 
 
- web.xml          
- Example of using a ServletContextListener
No comments:
Post a Comment