Well, there still can be multiple instances. For instance, if you access the servlet in different ways. Every mapping of the servlet will beget a new instance. If you have a servlet class "com.mycompany.MyServlet" that you've given the name "myservlet", then the following will beget two instances of that servetl:
http://localhost:8080/myapp/servlet/com.mycompany.MyServlet
http://localhost:8080/myapp/servlet/myservlet
Then in you map "myservlet" to "/theservlet", now you have another instance with:
http://localhost:8080/myapp/theservlet
So, that is is 3 instances in all. However, it is still technically correct that given any one instance, the container will not create multiple instances of that instance, as Craig says.
Jake
At 06:07 PM 10/21/2002 -0500, you wrote:
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!
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 <[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, NickCraig McClanahan -- To unsubscribe, e-mail: <mailto:tomcat-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>
