You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Subramanya Sastry <sa...@cs.wisc.edu> on 2005/03/03 12:15:24 UTC

Equivalent of Resin "run-at" servlet configuration

Hello,

I am developing a Java web application, and one of the requirements is to run 
a particular servlet periodically, or even at specified times.  Resin provides 
this ability via its "run-at" configuration element for servlets in web.xml

Example Resin configuration:
   <servlet>
      <servlet-name>download</servlet-name>
      <servlet-class>DownloadNewsServlet</servlet-class>
      <run-at period='360m'/>
   </servlet>

However, I haven't found an equivalent configuration for Tomcat.  I searched
the web and was unsuccessful.  So, any pointers as to how I could achieve this
for Tomcat would be appreciated.

Thanks,
Subbu.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Equivalent of Resin "run-at" servlet configuration

Posted by Antony Paul <an...@gmail.com>.
AFAIK  Tomcat dont provide a replacement for this. It is not in
Servlet spec. Search in archives as it was asked a few weeks before.

rgds
Antony Paul


On Thu, 3 Mar 2005 16:45:24 +0530 (IST), Subramanya Sastry
<sa...@cs.wisc.edu> wrote:
> Hello,
> 
> I am developing a Java web application, and one of the requirements is to run
> a particular servlet periodically, or even at specified times.  Resin provides
> this ability via its "run-at" configuration element for servlets in web.xml
> 
> Example Resin configuration:
>    <servlet>
>       <servlet-name>download</servlet-name>
>       <servlet-class>DownloadNewsServlet</servlet-class>
>       <run-at period='360m'/>
>    </servlet>
> 
> However, I haven't found an equivalent configuration for Tomcat.  I searched
> the web and was unsuccessful.  So, any pointers as to how I could achieve this
> for Tomcat would be appreciated.
> 
> Thanks,
> Subbu.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Equivalent of Resin "run-at" servlet configuration

Posted by David Smith <dn...@cornell.edu>.
I think the Cocoon project has such a facility.  I'm not sure how 
complicated it would be to pull out that functionality, but their work 
might be worth looking at for this.

--David

Parsons Technical Services wrote:

> With all the questions and suggestions flying around, a question to 
> the other programmers: If one was to write a class for the purpose of 
> running classes at set times, what pitfalls would one need to watch for?
>
> I have a class that loads on startup and runs a continuous loop that 
> is timed (sleeps, wakes up, does something, sleeps again). It runs 
> fine, but I know that it could be better.
>
> Any guidance or suggestions would be appreciated. And maybe we could 
> create an add-on and post it for use in apps that need such a device.
>
> Thanks
>
> Doug
>
>
> ----- Original Message ----- From: "Nikola Milutinovic" 
> <Ni...@ev.co.yu>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Thursday, March 03, 2005 6:55 AM
> Subject: Re: Equivalent of Resin "run-at" servlet configuration
>
>
>> Subramanya Sastry wrote:
>>
>>> Hello,
>>>
>>> I am developing a Java web application, and one of the requirements 
>>> is to run a particular servlet periodically, or even at specified 
>>> times.  Resin provides this ability via its "run-at" configuration 
>>> element for servlets in web.xml
>>>
>>> Example Resin configuration:
>>>   <servlet>
>>>      <servlet-name>download</servlet-name>
>>>      <servlet-class>DownloadNewsServlet</servlet-class>
>>>      <run-at period='360m'/>
>>>   </servlet>
>>>
>>> However, I haven't found an equivalent configuration for Tomcat.  I 
>>> searched
>>> the web and was unsuccessful.  So, any pointers as to how I could 
>>> achieve this
>>> for Tomcat would be appreciated.
>>>
>>
>> There is none and shouldn't be any. I understand the need to run 
>> periodical tasks, but J2EE specification, prior to 1.4 has no such 
>> provisions. Further, Servlet/JSP specification has no such provision, 
>> even in J2EE 1.4. You'd be best advised to setup a cron-job to 
>> perform this periodic activity. There are several good HTTP client 
>> packages out there, Jakarta-Commons HTTPclient, to name one, that 
>> will help you in building the client side of your cron-job.
>>
>> Nix.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Equivalent of Resin "run-at" servlet configuration

Posted by Jonathan Wilson <jn...@dallas.photronics.com>.
Well, I use a servlet that is kicked off at container start(On TC 3.x 
used <load-on-startup> attribute, TC 5.x+ there is something else which 
is now part of the J2EE spec). Most other containers have a 
<load-on-startup> type attribute available to them. When that servlet is 
init()ed at container start I kick off a class which loads more class 
names out of the web.xml that are Runnable. This parent class then kicks 
off a thread for each Runnable, and handles making sure they are all 
reaped when the destroy() method of the servlet is called(usually at 
container shutdown). There are better ways of doing this now with the 
newer TC's. If you don't shutdown your child threads, there may be a 
possibility that they will remain running after TC stops.

Good luck.

-JW

Lionel Farbos wrote:

>I think that what you want, with this feature, is a daemon (but not a servlet that respond to requests).
>So, 
>Tomcat don't have to implement anything for this (it's not in its sphere of activities).
>
>I think that crons (eventually with httpclients), TimerTasks, ... are more usefull for this need...
>
>On Thu, 3 Mar 2005 08:27:46 -0500
>"Parsons Technical Services" <pa...@earthlink.net> wrote:
>
>  
>
>>With all the questions and suggestions flying around, a question to the 
>>other programmers: If one was to write a class for the purpose of running 
>>classes at set times, what pitfalls would one need to watch for?
>>
>>I have a class that loads on startup and runs a continuous loop that is 
>>timed (sleeps, wakes up, does something, sleeps again). It runs fine, but I 
>>know that it could be better.
>>
>>Any guidance or suggestions would be appreciated. And maybe we could create 
>>an add-on and post it for use in apps that need such a device.
>>
>>Thanks
>>
>>Doug
>>
>>
>>----- Original Message ----- 
>>From: "Nikola Milutinovic" <Ni...@ev.co.yu>
>>To: "Tomcat Users List" <to...@jakarta.apache.org>
>>Sent: Thursday, March 03, 2005 6:55 AM
>>Subject: Re: Equivalent of Resin "run-at" servlet configuration
>>
>>
>>    
>>
>>>Subramanya Sastry wrote:
>>>
>>>      
>>>
>>>>Hello,
>>>>
>>>>I am developing a Java web application, and one of the requirements is to 
>>>>run a particular servlet periodically, or even at specified times.  Resin 
>>>>provides this ability via its "run-at" configuration element for servlets 
>>>>in web.xml
>>>>
>>>>Example Resin configuration:
>>>>  <servlet>
>>>>     <servlet-name>download</servlet-name>
>>>>     <servlet-class>DownloadNewsServlet</servlet-class>
>>>>     <run-at period='360m'/>
>>>>  </servlet>
>>>>
>>>>However, I haven't found an equivalent configuration for Tomcat.  I 
>>>>searched
>>>>the web and was unsuccessful.  So, any pointers as to how I could achieve 
>>>>this
>>>>for Tomcat would be appreciated.
>>>>
>>>>        
>>>>
>>>There is none and shouldn't be any. I understand the need to run 
>>>periodical tasks, but J2EE specification, prior to 1.4 has no such 
>>>provisions. Further, Servlet/JSP specification has no such provision, even 
>>>in J2EE 1.4. You'd be best advised to setup a cron-job to perform this 
>>>periodic activity. There are several good HTTP client packages out there, 
>>>Jakarta-Commons HTTPclient, to name one, that will help you in building 
>>>the client side of your cron-job.
>>>
>>>Nix.
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>  
>

Re: Equivalent of Resin "run-at" servlet configuration

Posted by Lionel Farbos <li...@free.fr>.
I think that what you want, with this feature, is a daemon (but not a servlet that respond to requests).
So, 
Tomcat don't have to implement anything for this (it's not in its sphere of activities).

I think that crons (eventually with httpclients), TimerTasks, ... are more usefull for this need...

On Thu, 3 Mar 2005 08:27:46 -0500
"Parsons Technical Services" <pa...@earthlink.net> wrote:

> With all the questions and suggestions flying around, a question to the 
> other programmers: If one was to write a class for the purpose of running 
> classes at set times, what pitfalls would one need to watch for?
> 
> I have a class that loads on startup and runs a continuous loop that is 
> timed (sleeps, wakes up, does something, sleeps again). It runs fine, but I 
> know that it could be better.
> 
> Any guidance or suggestions would be appreciated. And maybe we could create 
> an add-on and post it for use in apps that need such a device.
> 
> Thanks
> 
> Doug
> 
> 
> ----- Original Message ----- 
> From: "Nikola Milutinovic" <Ni...@ev.co.yu>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Thursday, March 03, 2005 6:55 AM
> Subject: Re: Equivalent of Resin "run-at" servlet configuration
> 
> 
> > Subramanya Sastry wrote:
> >
> >>Hello,
> >>
> >>I am developing a Java web application, and one of the requirements is to 
> >>run a particular servlet periodically, or even at specified times.  Resin 
> >>provides this ability via its "run-at" configuration element for servlets 
> >>in web.xml
> >>
> >>Example Resin configuration:
> >>   <servlet>
> >>      <servlet-name>download</servlet-name>
> >>      <servlet-class>DownloadNewsServlet</servlet-class>
> >>      <run-at period='360m'/>
> >>   </servlet>
> >>
> >>However, I haven't found an equivalent configuration for Tomcat.  I 
> >>searched
> >>the web and was unsuccessful.  So, any pointers as to how I could achieve 
> >>this
> >>for Tomcat would be appreciated.
> >>
> >
> > There is none and shouldn't be any. I understand the need to run 
> > periodical tasks, but J2EE specification, prior to 1.4 has no such 
> > provisions. Further, Servlet/JSP specification has no such provision, even 
> > in J2EE 1.4. You'd be best advised to setup a cron-job to perform this 
> > periodic activity. There are several good HTTP client packages out there, 
> > Jakarta-Commons HTTPclient, to name one, that will help you in building 
> > the client side of your cron-job.
> >
> > Nix.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Equivalent of Resin "run-at" servlet configuration

Posted by Parsons Technical Services <pa...@earthlink.net>.
With all the questions and suggestions flying around, a question to the 
other programmers: If one was to write a class for the purpose of running 
classes at set times, what pitfalls would one need to watch for?

I have a class that loads on startup and runs a continuous loop that is 
timed (sleeps, wakes up, does something, sleeps again). It runs fine, but I 
know that it could be better.

Any guidance or suggestions would be appreciated. And maybe we could create 
an add-on and post it for use in apps that need such a device.

Thanks

Doug


----- Original Message ----- 
From: "Nikola Milutinovic" <Ni...@ev.co.yu>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Thursday, March 03, 2005 6:55 AM
Subject: Re: Equivalent of Resin "run-at" servlet configuration


> Subramanya Sastry wrote:
>
>>Hello,
>>
>>I am developing a Java web application, and one of the requirements is to 
>>run a particular servlet periodically, or even at specified times.  Resin 
>>provides this ability via its "run-at" configuration element for servlets 
>>in web.xml
>>
>>Example Resin configuration:
>>   <servlet>
>>      <servlet-name>download</servlet-name>
>>      <servlet-class>DownloadNewsServlet</servlet-class>
>>      <run-at period='360m'/>
>>   </servlet>
>>
>>However, I haven't found an equivalent configuration for Tomcat.  I 
>>searched
>>the web and was unsuccessful.  So, any pointers as to how I could achieve 
>>this
>>for Tomcat would be appreciated.
>>
>
> There is none and shouldn't be any. I understand the need to run 
> periodical tasks, but J2EE specification, prior to 1.4 has no such 
> provisions. Further, Servlet/JSP specification has no such provision, even 
> in J2EE 1.4. You'd be best advised to setup a cron-job to perform this 
> periodic activity. There are several good HTTP client packages out there, 
> Jakarta-Commons HTTPclient, to name one, that will help you in building 
> the client side of your cron-job.
>
> Nix.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Equivalent of Resin "run-at" servlet configuration

Posted by Nikola Milutinovic <Ni...@ev.co.yu>.
Subramanya Sastry wrote:

>Hello,
>
>I am developing a Java web application, and one of the requirements is to run 
>a particular servlet periodically, or even at specified times.  Resin provides 
>this ability via its "run-at" configuration element for servlets in web.xml
>
>Example Resin configuration:
>   <servlet>
>      <servlet-name>download</servlet-name>
>      <servlet-class>DownloadNewsServlet</servlet-class>
>      <run-at period='360m'/>
>   </servlet>
>
>However, I haven't found an equivalent configuration for Tomcat.  I searched
>the web and was unsuccessful.  So, any pointers as to how I could achieve this
>for Tomcat would be appreciated.
>  
>

There is none and shouldn't be any. I understand the need to run 
periodical tasks, but J2EE specification, prior to 1.4 has no such 
provisions. Further, Servlet/JSP specification has no such provision, 
even in J2EE 1.4. You'd be best advised to setup a cron-job to perform 
this periodic activity. There are several good HTTP client packages out 
there, Jakarta-Commons HTTPclient, to name one, that will help you in 
building the client side of your cron-job.

Nix.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Equivalent of Resin "run-at" servlet configuration

Posted by QM <qm...@brandxdev.net>.
: I am developing a Java web application, and one of the requirements is to run 
: a particular servlet periodically, or even at specified times.  Resin provides 
: this ability via its "run-at" configuration element for servlets in web.xml

Tomcat doesn't have this.

Are you trying to run that particular servlet, or just the business
logic called by that servlet?

Look into a scheduler (such as Quartz) to call that business logic for
you at given times.

You could also use Java's builtin TimerTask class, but (IIRC) that takes
a Runnable or a Thread, so it's up to you to make sure those threads are
properly terminated at container shutdown.  Tomcat won't do that for
you.

-QM

-- 

software  -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org