Craig R. McClanahan wrote:

May be my question is not too close to this topic, but it may be related. It is below...

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.
I'm not familiar with Tomcat internal, but doesn't Tomcat instantiate a new servlet for each request to it?

A have to implement some functionality that related to multiple instances. I need a servlet which accepts common http requests from client-side applets. When a next request arrives, servlet must register a client somehow (for example, store its name and, possibly, access password) and not to close a connection. And, at any time (may be seconds, minutes or even hours), it have to send every client some portion of information based on client's needs. In other words, it's a server-push.
So, I need to share an information between servlets so each of them cat send it to corresponding client.

How can I do this? This task is too complicated for me, since I'm only starting write in Java.

Thank you for every answer!



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

Reply via email to