ServletContextListener:
1) what: listening ServletContext object is created or destroyed Servlet listener
2)how:
> Create a class that implements ServletContextListener, and wherein the method implements two
public class HelloServletContextListener implements ServletContextListener
> Configuration Listener in the web.xml file
<listener> <listener-class>listener.HelloListener</listener-class> </listener>
3) why: ServletContextListener The Listener is the most commonly used, may be initializing operation of the current web application resources in the current web application is loaded: creating a database connection pool, creating a Spring IOC container, reads the current WEB application initialization parameters. . .
4) API:
// ServletContext object is created (ie, the current WEB application is loaded) when, Servlet container calls this method.
@Override public void the contextInitialized (ServletContextEvent SCE) { } // ServletContext before an object is destroyed (i.e., the current WEB application is uninstalled) when, Servlet container calls the method @Override public void the contextDestroyed (ServletContextEvent SCE) { } ServletContextEvent in : getServletContext () Gets ServletContext
ServletRequestListener & HttpSessionListener
1) and similar ServletContextListener