Passa ai contenuti principali

Post

Visualizzazione dei post con l'etichetta tomcat context listener example

Tomcat context listener example

When a web application is deployed a servlet context object, ServletContext , is created and associated with the web application. There is a one-to-one relationship between a servlet context object and the web application. All resources within the web application , such as servlets and JSPs, can retrieve any information stored in the servlet context. '); As a web application programmer, you may want to initialize objects and place them in the servlet context when it is created and destroy the objects when the servlet context is destroyed. For example, you may decide to create a connection to a database when the servlet context is created and close the connection when the servlet context is destroyed. To write an application lifecycle event listener that executes when the servlet context is created and destroyed, write a Java class that implements the javax.Servlet.ServletContextListener class. This class has two methods with the following signatures (taken from the JavaDocs): void...