File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Periodically calling a servlet.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Periodically calling a servlet.." Watch "Periodically calling a servlet.." New topic

Periodically calling a servlet..

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902

hi ranchers,,
i created a simple Servlet and ran it on Apache Tomcat. This servlet reads an xml file from host url and stores data into DB, now my question is I want this servlet shuld be run after each 24 hrs on daily . i.e Say every night at 12:00 am my servlet revokes and parse xml file routine.

So what should i do, ? Is there any facility in Tomcat server which invoke specific servlet after fixed time of interval ??

PL help ranchers.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Joe Ess

Joined: Oct 29, 2001
Posts: 8836

Originally posted by Sagar Rohankar:
Is there any facility in Tomcat server which invoke specific servlet after fixed time of interval ??

I use cron to run periodic tasks. Windows has similar functionality in at, schtasks or task scheduler.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41124
You shouldn't use a servlet if you are not using it for HTTP access. If you want to run code periodically in a servlet container, use a javax.servlet.ServletContextListener in conjunction with a java.util.Timer and a java.util.TimerTask.

Ping & DNS - my free Android networking tools app
I agree. Here's the link:
subject: Periodically calling a servlet..
Similar Threads
Executing my first servlet program
servlet 404 error
Cache Problem
Access xml from servlet
Error: Namespace not supported by SAXParser