I think your need is to have an application (regardless of the Internet or not a website) that starts with tomcat at the same time.
, -, ( , tomcat) .
web.xml, :
<listener>
<description>application startup and shutdown events</description>
<display-name>ApplicationListener</display-name>
<listener-class>com.myapp.server.config.ApplicationListener</listener-class>
</listener>
ApplicationListener ServletContextListener. :
import java.io.File;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class ApplicationListener implements ServletContextListener {
private static Logger logger = Logger.getLogger(ApplicationListener.class);
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
logger.info("class : context destroyed");
}
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
ServletContext context = servletContextEvent.getServletContext();
logger.info("myapp : context Initialized");
}
}