I am using Tomcat with the Spring framework. I want to have a class called by the server every 30 minutes. Is there a good way to do this in Servlet, Spring, or Struts?
Asked
Active
Viewed 1,154 times
1
-
2This solution is probably your best bet. http://stackoverflow.com/questions/2039349/is-it-possible-to-run-a-cron-job-in-a-web-application – CamelSlack Oct 13 '11 at 18:30
-
4You might want to accept some answers to your previous questions too. – andronikus Oct 13 '11 at 18:35
-
1possible duplicate of [Background timer task in JSP/Servlet web application](http://stackoverflow.com/questions/5357033/background-timer-task-in-jsp-servlet-web-application) – Perception Oct 13 '11 at 18:36
2 Answers
3
Try this:
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/scheduling.html

andronikus
- 4,125
- 2
- 29
- 46
-2
You could create a new Thread
on container startup that sleeps for 30 minutes and then performs your action. See here for information about context listeners.

spork
- 1,185
- 1
- 11
- 17
-
4A sleeping `Thread` is an extremely bad idea on a lifelong running Java EE container. – BalusC Oct 13 '11 at 18:36