On 11/04/02 7:25, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

> From: Kelly Prudente Pereira [mailto:[EMAIL PROTECTED]]
> Sent: quarta-feira, 10 de Abril de 2002 23:04
> To: '[EMAIL PROTECTED]'
> Subject: How can I automatically start a servlet in a specific time?
> 
> 
> Can anyone answer my question?
> How can I automatically start a servlet in a specific time? For example: at
> midnight. 
> I don't want to start it when I start my webserver.
> 
> Thanks in advanced,
> 

Ola Kelly,

Posso falar em ingl�s?  Se n�o pe�a-me devolta e eu fa�o a tradu��o.

I do exactly this to schedule various tasks such as periodic emails of
database generated reports and logging details.  If you are using JDK 1.3.x
use the Timer and TimerTask.  They are very straightforward.  A simple demo
can be found at: 
http://java.sun.com/docs/books/tutorial/essential/threads/timer.html

I wholeheartedly disagree with the FAQ @ Distributopia.  I think servlets
are the best way to schedule tasks and they can be packaged with your
application on whatever platform that you deploy on.  You definitely do not
want to run this from cron or any other platform dependent process (even if
you did JCrontab exists and is a Java alternative to Cron).

The problem with the servlet method I have found is guaranteeing that only
one instance of your servlet is instantiated.  This is a real problem with
Tomcat and you must go to lengths to insure a singleton pattern is not
invoked at least twice (once by Tomcat classloader and once by your
application classloader).  If you find you are having this problem let me
know.

HTH

Steven

 
///* 
* VTV Learning Corporation
*        Los Angeles  -  Boston  -  Lisbon
*           (http://www.vtvLearning.com/)
*/


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to