Listener classes for servlet context and session changes
The following methods are defined as part of the javax.servlet.ServletContextListener interface:
- void contextInitialized(ServletContextEvent) - Notification that
the Web application is ready to process requests.
Place code in
this method to see if the created context is for your Web application
and if it is, allocate a database connection and store the connection
in the servlet context.
- void contextDestroyed(ServletContextEvent) -Notification that
the servlet context is about to shut down.
Place code in this
method to see if the created context is for your Web application and
if it is, close the database connection stored in the servlet context.
Two new listener interfaces are defined as part of the javax.servlet
package:
- ServletContextListener
- ServletContextAttributeListener
One new filter interface is defined as part of the javax.servlet
package:
- FilterChain interface - methods: doFilter()
Two new event classes are defined as part of the javax.servlet
package:
- ServletContextEvent
- ServletContextAttributeEvent
Three new listener interfaces are defined as part of the javax.servlet.http
package:
- HttpSessionListener
- HttpSessionAttributeListener
- HttpSessionActivationListener
One new event class is defined as part of the javax.servlet.http
package:

Application lifecycle listeners and events

Example: com.ibm.websphere.DBConnectionListener.java
Web applications: Resources for learning
Searchable topic ID:
rweb_listeners
Last updated: Jun 21, 2007 8:07:48 PM CDT
WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/ae/rweb_listeners.html