aspose file tools*
The moose likes Servlets and the fly likes load-on-startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "load-on-startup" Watch "load-on-startup" New topic
Author

load-on-startup

James Clarke
Ranch Hand

Joined: Oct 04, 2004
Posts: 148
Hi all,

If I initiate a servlet inside <load-on-startup> and have an infinite
loop inside the servlet ie. for(; , would this cause major performance
problems in terms of the server, servlet container etc. ?

thanks,

J.C
Jaime M. Tovar
Ranch Hand

Joined: Mar 28, 2005
Posts: 133
Never tried it but let me ask why you are doing that???


She will remember your heart when men are fairy tales in books written by rabbits.<br /> As long as there is duct tape... there is also hope.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Sorry if I sound rude, but the question seems so silly as to almost be a joke. Of course you are going to introduce performance issues if you put elements into infinite loops.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

I had a kind of similar question - posted here a couple of weeks back. Dint get any helpful replies though. Sorry if I sound silly or stupid, but why is it worong to have a infinite loop running somewhere in a web application? In my case, I need to have a thread that polls a log file every, say, 5 seconds. I am not in favour of having a Servlet do this task - would assign it to a ContextListener rather.

Thanks,
Ram.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Just putting an endless loop in the init method would keep the init method from returning.

If you want something to run continuously in the background, you would want start a separate thread.
There are APIs specifically designed for this.
Check out java.util.Timer or Quartz.

The following article might be of interest to you:
http://www.onjava.com/pub/a/onjava/2004/03/10/quartz.html?page=1


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: load-on-startup