On Thu, 29 Aug 2002, Rui Fernandes wrote:
> Date: Thu, 29 Aug 2002 17:30:13 +0200
> From: Rui Fernandes <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: RE: Servlet Instances
>
> I don't understand what you say.
> Would you be able to explain it again in more detail.
>
Consider the following scenario:
(1) In $CATALINA_HOME/webapps you have the following directories:
ROOT/ The root webapp
examples/ The Tomcat examples webapp
myapp/ My custom application
(2) In server.xml you add a declaration like this:
<Context path="/yourapp" docBase="myapp" ...>
What will happen is that the web application in directory "myapp" will get
deployed twice -- once under context path "/myapp" because directories in
the "webapps" directory are automatically mounted, and once under context
path "/yourapp" because of the explicit <Context> declaration. As a
consequence, any load-on-startup servlet will appear to get initialized
twice -- once per webapp.
Other possible user configuration errors that can cause this kind of
thing:
* Mistakenly declaring your servlet in $CATALINA_HOME/conf/web.xml
instead of in the /WEB-INF/web.xml for your webapp. The global
file is loaded for *every* webapp, so you'd see as many initializations
of your servlet as there are webapps.
* Using two different kinds of mappings for the same servlet:
- /myapp/servlet/com.mycompany.MyServlet -- through the invoker
- /myapp/some/other/mapping -- explicit <servlet-mapping>
The "one instance" guarantee is per servlet *definition*, not per
mapping. The first of these dynamically creates a new servlet
definition, different from any that might be related to a mapping.
* Using SingleThreadModel -- Tomcat will create a pool of instances
if your servlet implements this interface
Craig
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>