DBConnectionPoolListener will (Ftp web hosting) receive event notifications when the ServletContext

DBConnectionPoolListener will receive event notifications when the ServletContext is initialized and destroyed. Example 15-4. The DBConnectionPoolListener class import javax.servlet.ServletContextListener; import javax.servlet.ServletContextEvent; /** * An example event listener class that * initializes the database connection pooling. */ public class DBConnectionPoolListener implementsServletContextListener{ /** * Called by the container before the first request is * processed. This is a good time to initialize * the connection pooling service. */ public void contextInitialized( ServletContextEvent event ){ // Initialize the connection pooling here } /** * Called by the container when the ServletContext is about * ready to be removed. This is a good time to clean up * any open resources. */ public void contextDestroyed( ServletContextEvent event ){ // Shut down the connection pooling and open databaseconnections } } Because both the LoggingListenerand DBConnectionPoolListener are listening for the same type of application events, the servlet container will notify them in the order in which they are listed in the descriptor, based on the event type. 15.2.4.2 Declaring the event listener in the deployment descriptor The following web application deployment descriptor fragment shows you how to set up the event listeners:
LoggingListener DBConnectionPoolListenerGo visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Leave a Reply