tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: multiple servlet instances?
Date Tue, 22 Oct 2002 03:50:46 GMT


On Mon, 21 Oct 2002, Nick Wesselman wrote:

> Date: Mon, 21 Oct 2002 18:07:42 -0500
> From: Nick Wesselman <nick@digivis.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> 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.

Craig McClanahan



> Nick
>
> On Monday, October 21, 2002, at 05:22 PM, Craig R. McClanahan wrote:
>
> >
> >
> > On Mon, 21 Oct 2002, Nick Wesselman wrote:
> >
> >> Date: Mon, 21 Oct 2002 16:49:18 -0500
> >> From: Nick Wesselman <nick@digivis.com>
> >> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> >> To: tomcat-user@jakarta.apache.org
> >> Subject: multiple servlet instances?
> >>
> >> I was reading in a book today that "JSP implementations are still
> >> permitted to create multiple instances of the ... servlet in order to
> >> provide improved performance." Does Tomcat/Jasper do this? Might there
> >> be multiple instances of a servlet (JSP-generated or otherwise) in my
> >> JVM?
> >>
> >
> > You might want to be cautious believing anything that book says about
> > any
> > topic, unless it correctly explains what is really going on.  What book
> > said this?
> >
> > For anything from Servlet 2.2 on (that's quite a long while back), it
> > is
> > not legal for the container to create more than one instance of a
> > particular servlet definition *unless* that servlet implements the
> > SingleThreadModel interface (or the JSP page has the
> > isThreadSafe="false" attribute on its <%@ page %> directive).
> >
> > The other thing to note is that doing this would not improve
> > performance
> > -- at best, it will have zero impact, but it's actually pretty likely
> > to
> > be negative (because the container is going to have to manage the
> > multiple
> > instances, because the maximum number of simultaneous requests to that
> > servlet is now limited to the pool size you've configured, and because
> > they take up more memory space).
> >
> > The only reason that SingleThreadModel exists is to allow you to
> > create a
> > servlet or JSP page that stores per-request state information in
> > instance
> > variables of the underlying class.  This is not a good programming
> > practice -- you should instead use local variables only, so that a
> > single
> > instance of your servlet or JSP page can handle any number of
> > simultaneous
> > requests.
> >
> >> Thanks,
> >> Nick
> >
> > Craig McClanahan
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:tomcat-user-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message