tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Randy Secrist" <tom...@secristfamily.com>
Subject Re: Servlet Instances
Date Thu, 29 Aug 2002 04:48:26 GMT
You can't explicitly control how many instances a container may create of
your servlet since you don't have control over the container code.  (Unless
you hack the container that is.)  If you do hack, you might as well write
your own servlet specification since you would have to change many of the
interfaces.  This isn't very reasonable.  (You can't make the constructor
private and make it a singleton since a servlet must conform to a
HttpServlet interface.)

What most people do when they have this need, is let the container call the
servlet to it's hearts content, and ensure that any objects the servlet
references are only instantiated one time.  (Via singletons, static classes,
etc.).  However - since these objects usuallly have synchronized methods, if
your site gets a lot of traffic, the container won't be taking advantage of
it's multi threaded abilities, and each request will have to block on any
synchronized sections of code you have.

In a large traffic application, I would use a DBMS / EJB system which
offloads much of the servlet transactionality.

Randy

----- Original Message -----
From: "Rui Fernandes" <rui@entalpia.com>
To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
Sent: Wednesday, August 28, 2002 1:11 PM
Subject: Servlet Instances


How should I control how many instances I want of a given servlet?
In my case I would like just one.




--
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