If you want a servlet to init as part of your web app then you should
define it in your web app's WEB-INF/web.xml file with the following syntax:
web-app
servlet
servlet-nameput your servlet's name here/servlet-name
servlet-classservlet.class.name.here/servlet-class
init-param
param-namenameOfParamMappingToMutatorOnServlet/param-name
param-valueput the value of the parameter
here/param-value
/init-param
/servlet
etc., ...
I believe that this will result in the execution of the servlet's init()
method. Incidentally, mutator is synonymous for setter (e.g., setFoo(
String val)) if that's unclear. You can also have any number of init-param
elements.
Evan
---
To design, to implement, to maintain, and not to kluge.
Julia Kuznetsov
julia_kuznetsov@modusTo:
[EMAIL PROTECTED]
media.comcc:
Subject: How to specify a
startup servlet for an application
06/27/01 01:34 PM (CONTEXT)?
Please respond to
tomcat-user
I need to load couple xml files into memory and store them in
ServletContext
when my application starts. I created a servlet to do that, but I can't
figure out how to make this servlet run automatically whem the app starts.
Is there smthg in server.xml that I can define to run this servlet?
Please help!
Julia Kuznetsov