tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Init() being called 3 times
Date Fri, 29 Dec 2000 20:35:18 GMT
Marc Saegesser wrote:

> In Tomcat 3.2.x, specifying more than one name for a servlet in web.xml
> causes a separate instance to be created for each name and each instances
> init() method will et invoked.  Essentially creating a new servlet for each
> name as opposed to multiple names for a single instance of the servlet.
>
> The Servlet 2.2 spec (at least by my reading) doesn't provide clear guidance
> on the real behaviour of the <servlet-name> tag and the behaviour may vary
> from one servlet container to another.  I seem to recall that JRun, for
> example, didn't create multiple instances.
>

The spec is actually pretty clear ... for a servlet that does not implement
SingleThreadModel, there will be one servlet instance created per servlet
*definition* -- in other words, for each <servlet> element in your web.xml file,
even if they refer to the same servlet class.

In addition, if you use the invoker facility (/servlet/{servlet-class-name}) to
reference the same servlet class, that creates a new definition on the fly,
independent of any other definitions in web.xml.

Craig McClanahan

Mime
View raw message