You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christof Soehngen <so...@nts-online.de> on 2001/09/27 17:46:05 UTC

Timeout via EventListener

Hi there,

I noticed, that some people (including me) are in need of a possibility to
control the execution time of a servlet.

Now, some thaughts later, I remembered that there is something thats called
EventListeners. Problem is, I don't know very much about them, nothing to be
exact ;)

Could this be a way, is there an eventlistener that works like a clock,
where servlets could be bound to, some how shutting themselves down?

Thanks, Christof


RE: Timeout via EventListener

Posted by George McKInney <ge...@tantalus.com>.
I don't think you need to use an event listener. My top-of-the-head
suggestion would be (if you're using Java1.3+) to have the servlet (or some
other part of the app) create a Timer (see the Java1.3+ docs), and then to
have the servlet create a TimerTask and schedule it with the Timer before it
goes into the code that might take a long time. The task (if not cancelled)
would do whatever is necessary to tell the code to give up. A prompt return
would cause a cancel() of the Task.

You would need to be careful to release all resources (Threads, jdbc
connections) that were in use.

Hope this helps.

George McKinney, Developer
Tantalus Communications Inc.
500-1122 Mainland Street
Vancouver, BC, Canada V6B 5L1
george@tantalus.com

Direct  604.726.6753
Main    604.609.0700
Fax     604.609.0705

"The Oracle Experts"
www.tantalus.com


> -----Original Message-----
> From: Christof Soehngen [mailto:soehngen@nts-online.de]
> Sent: Thursday, September 27, 2001 8:46 AM
> To: Tomcat User Group
> Subject: Timeout via EventListener
>
>
> Hi there,
>
> I noticed, that some people (including me) are in need of a
> possibility to
> control the execution time of a servlet.
>
> Now, some thaughts later, I remembered that there is
> something thats called
> EventListeners. Problem is, I don't know very much about
> them, nothing to be
> exact ;)
>
> Could this be a way, is there an eventlistener that works
> like a clock,
> where servlets could be bound to, some how shutting themselves down?
>
> Thanks, Christof
>
>