Your problem is that you misunderstand the purpose of the servlet.
It's intented to act on HTTP requests, nothing more. You want just a
background task which runs once on daily basis. For that Quartz or even
ScheduledExecutorService is perfect. This needs to be initiated by a ServletContextListener . Here's a kickoff example:
Where the class UpdateCounts look like this:
To get the ServletContextListener to run, just register it in web.xml as follows:
Or, when you're already on Servlet 3.0, just annotate it with @WebListener
|
Thursday, December 13, 2012
How to keep the servlet continously running?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment