Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes PollServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "PollServlet" Watch "PollServlet" New topic
Author

PollServlet

ib idris
Greenhorn

Joined: Aug 02, 2003
Posts: 29
Hi,
how do I setup a servlet to execute a method every 3 hours. The method does nothing special it reads a URL with a table and detects cahneges in the table. Changes are then saved to DB or HD. The method itself is not a problem. I am trying to figure out how to do the polling
Can I have a service methode with Infinite loop and thread that sleeps for 3 hours or is there a better way.
Thanks for you help.
http://galileo.spaceports.com/~ibidris/
Dani Mazzuca
Ranch Hand

Joined: May 21, 2003
Posts: 70
Hi,
Well, the requirements are some strange, I mean, why do you need to write it in a servlet? Why don't you use a java stand-alone application instead?
Anyway, the following classes (and other related) should be very useful for in your case:
java.util.Timer
Java.util.TimerTask
Dani
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12757
    
    5
That sounds like a job for a helper class and certainly does not belong in servlet code. You could create an object attached to the ServletContext that implements Runnable.
Bill
 
 
subject: PollServlet
 
Similar Threads
Server Side Includes
Server-based Java Programming by Ted Neward
Using GridLayout
IDEA: web-based JSP editor for final markups...
What is the advantage of using useBean - Actions tag