Java EE enterprise applications: some actions for deployment / startup
•
Java
See English answer > using special auto start servlet to initialize on startup and share application data1
thank you.
Solution
Configure the servvetcontextlistener and override contextinitialized()
In your web application description, web xml
<web-app ...> <listener> <listener-class>com.someCompany.AppNameservletcontextlistener</listener-class> </listener> </web-app
package com.someCompany; import javax.servlet.ServletContextEvent; import javax.servlet.servletcontextlistener; public class AppNameservletcontextlistener implements servletcontextlistener{ @Override public void contextDestroyed(ServletContextEvent arg0) { System.out.println("servletcontextlistener destroyed"); } @Override public void contextInitialized(ServletContextEvent arg0) { System.out.println("servletcontextlistener started"); // do the things here } }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码