Hi,

I am not sure how you would go about doing this in Tomcat 4, but in
3.2.x,
in the $TOMCAT_HOME/webapps/yourwebapp/WEB-INF/web.xml file, you could
write a special XML tag and give the fully qualified classname of your
Java class (e.g. com.yourcompany.MyApplication) in those tags. When
Tomcat
starts, it will read all the web.xml files, and finding this tag
wrapping
your class, it will load that class. I've used this to make a static
JDBC
Connection Pool available to all web applications running in Tomcat.

you should probably make your class (MyApplication.java) extend Servlet.
Since Servlet has an init() method that will be called once, your
application
will be started by Tomcat, so you don't have to start it manually. Do
your work in init() rather than doGet() or doPost(), so people just
don't call
your servlet and make it do work all over again.

see $TOMCAT_HOME/webapps/text/WEB-INF/web.xml for more details
see $TOMCAT_HOME/conf/web.xml for more details

make sure your class (MyApplication.class) is in Tomcat's classpath

use this tag: <load-on-startup></load-on-startup>

<servlet>
        <servlet-name>
            myapplication
        </servlet-name>
        <servlet-class>
            com.mycompany.MyApplication
        </servlet-class>
        <load-on-startup>
            -2147483646
        </load-on-startup>
</servlet>

I'm not sure what the numbers mean :), but it has seemed to work for me.

I'm not sure this procedure is still valid in Tomcat 4 or if I've gotten
things mixed up in the explanation above, but it should be a start for
you.

regards,
Michael Locasto





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to