You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Beth Hechanova <bh...@imsconsultants.com> on 2007/10/19 01:17:05 UTC

Can Tomcat load a class on startup?

Hi,

 

I have a class file that I would like to have always running on my
machine, independent of any web application.  My machine includes an
LCD, and so this class file will be a listener to the LCD Interface that
can react to button presses.    This class can also potentially interact
with the website code if the user initiates current functions.

 

Ideally I'd like to package up this class in my website war file and
have tomcat instantiate this class when it starts up.  I didn't see
anything in the tomcat doc that looked like this was possible.

 

Alternately if this code can instead be packaged up in a separate jar
file that gets loaded at startup, that would work too.  And technically
this is probably "more correct" since this code needs to run independent
of the website code.

 

My goal is to have the LCD Listener running in the same jvm as Tomcat so
I don't have to deal with the issues with different jvm's.

 

Can Tomcat load a class on startup?

I'm running Tomcat v6.0.14 on a Linux Fedora machine.

 

Thanks,

Beth


Re: Can Tomcat load a class on startup?

Posted by David Kerber <dc...@verizon.net>.
Hassan Schroeder wrote:
> On 10/18/07, Beth Hechanova <bh...@imsconsultants.com> wrote:
>
>   
>> Can Tomcat load a class on startup?
>>     
>
> Yes. See `ServletContextListener` in the Servlet spec.
>
>   
Yep.  Works fine.  I use this to start several timers which generate 
reports and do other things at specific intervals.

D



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Can Tomcat load a class on startup?

Posted by Hassan Schroeder <ha...@gmail.com>.
On 10/18/07, Beth Hechanova <bh...@imsconsultants.com> wrote:

> Can Tomcat load a class on startup?

Yes. See `ServletContextListener` in the Servlet spec.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org