• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PollServlet

 
ib idris
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic