| Author |
Starting a scheduler on server start up
|
shobha devi
Greenhorn
Joined: Mar 11, 2009
Posts: 11
|
|
I developed a Java Web Application.
In the application, I wrote a scheduler, which is a java program that has main method, to perform certain operation if criteria is met. Now I want to start the scheduler when the application is started. Can anyone please help me how to accomplish the requirement.
|
 |
Ashish Hiriadka
Greenhorn
Joined: Feb 27, 2011
Posts: 5
|
|
you can use ServletContextListner right??
|
 |
abani patra
Ranch Hand
Joined: Oct 11, 2011
Posts: 70
|
|
Hi,
You can start the scheduler in init method of servlet so that on the 1st request it will be started.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
abani patra wrote:You can start the scheduler in init method of servlet so that on the 1st request it will be started.
You could certainly do that if you were working in an environment which didn't have ServletContextListeners. But if your environment has ServletContextListeners -- which it will unless it has been running without upgrades for the last 8 years or so -- you should use them.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56201
|
|
abani patra wrote:Hi,
You can start the scheduler in init method of servlet so that on the 1st request it will be started.
That was ok in 2002. In modern applications a context listener, as Paul suggested, is the way to go.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Starting a scheduler on server start up
|
|
|