In Quartz, a popular scheduler is a common practice for setting tasks in the servlet init method with the load-on-startup attribute set to true:
From this article in web.xml you should do this:
<servlet>
<servlet-name>QuartzInitializer</servlet-name>
<display-name>Quartz Initializer Servlet</display-name>
<servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
And then configure the jobs in your servlet:
public class QuartzServlet extends GenericServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
PS: I highly recommend you use Quartz
source
share