On Wed, 23 Oct 2002, Nick Wesselman wrote:
> Date: Wed, 23 Oct 2002 14:21:59 -0500
> From: Nick Wesselman <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: Re: multiple servlet instances?
>
> On Tuesday, October 22, 2002, at 11:30 AM, Craig R. McClanahan wrote:
>
> > The precise rule is that there is a single instance per servlet
> > *definition*, not per servlet *mapping*. A servlet definition is:
> >
> > * A single <servlet> element (no matter how many mappings point at it)
> > from your web.xml file
> >
> > * A dynamically created definition when you use the invoker servlet
> > (i.e. the /servlet/* mapping), which is a Tomcat feature and nothing
> > to do with the servlet specification.
> >
>
> Tomcat only creates a single definition for a servlet for use with all
> requests via the invoker, right? i.e., Multiple requests via the
> invoker use the same definition/servlet instance?
>
Yes. The first time you use the invoker with a particular path
("/servlet/MyServlet"), Tomcat does the following:
* Creates the internal equivalent of a new <servlet> definition
for the new servlet class.
* Creates the internal equivalent of a <servlet-mapping> for the
new servlet definition, using a URL pattern based on what you
submitted (in this case it would be "/servlet/MyServlet/*").
>From then on, for all subsequent requests, this servlet definition is
used, just as if you had manually defined the <servlet> and
<servlet-mapping> elements in web.xml yourself.
But, as I mentioned earlier, the invoker is a feature of Tomcat (and a few
other containers) -- it is not part of the Servlet Specification. In
addition, due to security concerns, the invoker is disabled by default
starting in 4.1.12. You can re-enable it by uncommenting the
<servlet-mapping> for it in $CATALINA_HOME/conf/web.xml, but you are much
better off to simply define the <servlet> and <servlet-mapping> elements
yourself.
> Nick
Craig
--
To unsubscribe, e-mail: <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>