Other than ContextListeners, you can also have a servlet in loading web.xml at startup:
<servlet> <servlet-name>mytask</servlet-name> <servlet-class>servlets.MyTaskServlet</servlet-class> ... <load-on-startup>1</load-on-startup> </servlet>
This servlet can run your task using any means you need, for example, a link.
But you should not use this approach, imho.
Use a proven / lib structure like quartz or a similar tool. There are many problems / problems when starting and synchronizing tasks on web servers, and it is better to use some proven tool than to repeat the errors that these tools have already encountered and solved. It may take some time to understand, but to avoid many headaches.
Jboss himself has a toolkit for this purpose: scheduling and task management. Never used, therefore not recommended.
jagra
source share