You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Bedrijven.nl" <ma...@bedrijven.nl> on 2004/05/06 08:10:06 UTC

RE: How to run servlet for every 30 minutes in Tomcat 4.1.30

Hi,

create a task in your scheduler that calls an URL with your servlet. That's
how we do background processes like sending newsletters etc.

Maarteb


-----Oorspronkelijk bericht-----
Van: Dennis Payne [mailto:DENNIS@mtctrains.com]
Verzonden: Tuesday, December 21, 2004 11:37 PM
Aan: tomcat-user@jakarta.apache.org
Onderwerp: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30


It is possible to create a servlet thread in the init() method.  That
thread sould stay alive and run something every thirty minutes.  The
issue of pushing information out to the user remins the same.  The
servlet and the thread cannot do that.  On the other hand, it is
possible to setup java script on the page to detect 30 minute intervals
to pull a page from the server.

It is an awful lot of work for so little a result... It is best just to
put a java process into cron or task scheduler and have the user run the
report when they want the info.

>>> jukka.uusisalo@dnainternet.net 12-21-2004 14:44 >>>
Jorge Sopena wrote:
> Why is bad using own threads inside web application?
> Aren't all the servlet request actually a thread in Tomcat?
> I can't find a reason why it's so bad solution.

I think that comes from J2EE specs. I do not remember is threads just
forbidden but if you follow specs, you do not know and you do not have
to know how application server uses threads and controls thread
behaviour. If portability is issue for your application, it is better
to
not use threads.

 >
> In that way, you manage to have a single and independent
application.
>
> Maybe I don't know some thread behaviour in Tomcat...
>

After all, I have use threads in web application with tomcat :) and I
haven't have any problems or strange thread behaviour. Sometimes whole

concurrent programming and syncronizing my own threads causes troubles

but nothing due tomcat.

Back to original question.

>  bernhard.slominski@zooplus.com wrote:
> I am using Tomcat4.1.30 version.
> I have to develop a client application which looks in the database
every 30
> minutes,

ApplicationContextListener + Timer + TimerTask


> to retrieve the status of an order and send the status to the remote
client.
> Again waits for the
> The client's response and insert the repsonse back to the database.

What is that remote client? Is actually another server and your
application is client. If so, just add client code for server in
TimerTask (http-, web service- or whatever client).

- Jukka -

---------------------------------------------------------------------
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