On Mon, 21 Oct 2002, Nick Wesselman wrote:
> Date: Mon, 21 Oct 2002 16:49:18 -0500 > From: Nick Wesselman <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > 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>
