tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikola Milutinovic <>
Subject Re: I need to run a servlet periodically
Date Sat, 05 Oct 2002 10:47:59 GMT
Filip Rachunek wrote:

> Hello,
> is it possible to have a servlet in Tomcat container
> which is invoked automatically each gived time period?
> [e.g. each 10 minutes]  And I would also need this
> special servlet to access other resources of my web
> application [connection pool, ...].

You're making a mistake. A Java Servlet is a Java component that responds to a 
web request. That's it - nothing more, nothing less, just what it is designed for.

It is not designed to be a "cron job". Something like that doesn't belong to a 
web application - or should we say, to the web GUI part of a web application. In 
a full JEE application which has a web portal (like Tomcat), you would place 
such a "cron job" somewhere other than a web interface. I'm not sure where, I'm 
no expert on JEE (yet).

This was like asking "can CGI script be configured to run at regular 
intervals?". Of course you could run a cron job that would act as a web client 
and send a request that would fire up that CGI or Servlet. But that is going 
slightly around it. And doing it at the wrong point.

Web applications are request driven application and should not be twisted into 
something unnatural. Use a regular cron job for this.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message