tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: multiple servlet instances?
Date Wed, 23 Oct 2002 02:29:10 GMT

On Wed, 23 Oct 2002, Jon Eaves wrote:

> Date: Wed, 23 Oct 2002 11:53:29 +1000
> From: Jon Eaves <>
> Reply-To: Tomcat Users List <>
> To: Tomcat Users List <>
> Subject: Re: multiple servlet instances?
> Craig R. McClanahan wrote:
> >
> > On Mon, 21 Oct 2002, Nick Wesselman wrote:
> >
> >
> >>Date: Mon, 21 Oct 2002 18:07:42 -0500
> >>From: Nick Wesselman <>
> >>Reply-To: Tomcat Users List <>
> >>To: Tomcat Users List <>
> >>Subject: Re: multiple servlet instances?
> >>
> >>the book was actually referring to the case where isThreadSafe="false"
> >>... it uses misleading wording, however.
> >>
> >>"... you also need to be aware that, even if a JSP page sets the
> >>isThreadSafe attribute to false, JSP implementations are still
> >>permitted to create multiple instances of the corresponding servlet..."
> >>(my emph)
> >>
> >>"Web Development with Java Server Pages" by Duane Fields and Mark Kolb
> >>... p. 62 ... I just got a fax of the page in reference to a question
> >>from a client. Thanks for your help!
> >>
> >
> > I would need one of the authors to substantiate where in the JSP specs
> > they see the support for the assertion that multiple instances are
> > allowed.  I cannot find any evidence to support this in the JSP 1.2
> > specification (which the current edition purports to cover).
> >
> > Further, I'm *very* skeptical about any claim that multiple instances of
> > the servlet running behind your JSP page would actually provide any
> > performance benefits, even if it were allowed by the specification.
> Servlet Specification p22-23
> SRV2.2 Number of Instances
> The servlet declaration which is part of the deployment descriptor of the
> web application containing the servlet, as described in Chapter SRV.13,
> “Deployment Descriptor”, controls how the servlet container provides
> instances of the servlet. For a servlet not hosted in a distributed
> environment (the default), the servlet container must use only one instance
> per servlet declaration. However, for a servlet implementing the
> SingleThreadModel interface, the servlet container may instantiate multiple
> instances to handle a heavy request load and serialize requests
> to a particular instance."
> I took that section of the specification to mean that multiple instances
> of servlets can be created iff the SingleThreadModel interface is implemented.

That is correct -- but there is still a subtlety when there's more than
one mapping for the same servlet.  Consider a web.xml file with:




If the MyFooServlet class does not implement SingleThreadModel, there will
be one and only one instance of the "foo" servlet created, no matter now
many different URLs you use to access it.

Hence, my clarification that it is one instance per servlet *definition*
(i.e. a <servlet> element), not one instance per servlet *mapping* as
someone else mistakenly said.

> Of course, that's just a reading of the spec and I'm not part of that JSR
> so I could be interpreting it incorrectly.  I would be interested in a
> clarification though.
> Cheers,
> 	-- jon


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message