tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anoop kumar V <anoopkum...@gmail.com>
Subject Re: How to load a class when tomcat starts
Date Sat, 10 Dec 2005 14:54:07 GMT
The way we have done is to load a servlet during startup (very easy to do in
web.xml) and through this servlet use Class.forName("classname") to load the
required classes into memory.

The reason we do this is to read a .properties file and store all the name
value pairs in a hashmap to be retrieved by various classes at run time.

Hope that helps,
Anoop

On 12/10/05, Richard Mixon <rnmixon@qwest.net> wrote:
>
> Vineesh,
>
> You should probably  use a ServletContextListener . It will give you
> control
> when the web application starts and when it ends, among otherevents. It is
> pretty well described in the servlet spec and is pretty simple.
>
> HTH -Richard
>
> -----Original Message-----
> From: vineesh kumar [mailto:vineeshkumarpv@gmail.com]
> Sent: Saturday, December 10, 2005 12:22 AM
> To: users@tomcat.apache.org
> Subject: How to load a class when tomcat starts
>
> Hi all,
>
> I need to load a java class when tomcat starts, which will initializes
> some
> configuration files and so i can use the fields in the class throught the
> environment.How can i do this.?
> Actually I am working on a distributed application, so the configuration
> files may change frequently but once the system is initialized it will not
> change until shut down.
> regards
> vineesh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


--
Thanks and best regards,
Anoop

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message