aspose file tools*
The moose likes Servlets and the fly likes Servlet Refreshing at Regular Intervals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Refreshing at Regular Intervals" Watch "Servlet Refreshing at Regular Intervals" New topic
Author

Servlet Refreshing at Regular Intervals

vaitheeswaran subramanian
Greenhorn

Joined: Jan 06, 2005
Posts: 15
I have a servlet that loads on start up. All it does is loads look up data and caches it. I want this servlet to reload at regular intervals (once in an hour) and refresh its cache. How do I do that?

Vaithee
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If your servlet is not responding to web request, it shouldn't be a servlet.
Use a ServletContextListener instead.
For making your object perform tasks at given intervals look at either java.util.Timer or, if you need more functionality look at the Quartz library.


Another approach is to go with a servlet, put the lookup code in doGet or doPost, and trigger it with a web request using wget and a cronjob. This keeps you from having to spawn your own threads in a web app.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
ashok ganesan
Ranch Hand

Joined: Jan 02, 2007
Posts: 50
[Removed Hi-Jack]
[ March 04, 2008: Message edited by: Ben Souther ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Hi Ashok,

Please enter your question in a new thread.
Adding to the bottom of someone else's is called hi-jacking and not a nice thing to do. It has a tendency to derail the conversation about the original poster's question.

-Ben
ashok ganesan
Ranch Hand

Joined: Jan 02, 2007
Posts: 50
oops sorry for the mistake
 
 
subject: Servlet Refreshing at Regular Intervals
 
Similar Threads
Automating Servlet Tasks
How To Trigger Timer Bean automatically in startup servlet?
Call a servlet in listener
Confuguring tomcat to Run Thread at rgular intervals of Time
For Load Balancing