aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes servlet pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servlet pool" Watch "servlet pool" New topic
Author

servlet pool

tony lee
Ranch Hand

Joined: Jan 21, 2002
Posts: 52
hi friends,
it seems confusing that there's a servlet pool in the single-thread model. if we implement a servlet SingleThreadModel, no two threads will execute concurrently in the servlet's service method. in this situation, what's the use of a pool of servlet instances? i think one instance is okay, right?
tony


SCJP2, SCWCD
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Hi Tony,
SingleThreadModel results in ThreadSave member variables of the servlet. If u have > 1 servlets (servlet-pool) the member variables per instance are still thread-safe.
A Servlet pool leads to faster response time. That makes sense to me, because SingleThreadModel slows down the response time.
tony lee
Ranch Hand

Joined: Jan 21, 2002
Posts: 52
hi axel,
do you know what's a servlet pool?
it's a number of servlet objects (instances) associated with the same servlet name. each of the instances is ready (initialized) to be dispatched to a request thread by the container. i'm not sure the defination i gave is right
any ideas on it, friends?
tony
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Maybe this will help...
3.2 Number of Instances
By default, there must be only one instance of a servlet class per servlet definition in a container.
In the case of a servlet that implements the SingleThreadModel interface, the servlet container
may instantiate multiple instances of that servlet so that it can handle a heavy request load while
still serializing requests to a single instance.
In the case where a servlet was deployed as part of an application that is marked in the deployment
descriptor as distributable, there is one instance of a servlet class per servlet definition per VM in a
container. If the servlet implements the SingleThreadModel interface as well as is part of a
distributable web application, the container may instantiate multiple instances of that servlet in
each VM of the container.
3.2.1 Note about SingleThreadModel
The use of the SingleThreadModel interface guarantees that one thread at a time will execute
through a given servlet instance’s service method. It is important to note that this guarantee only
applies to servlet instance. Objects that can be accessible to more than one servlet instance at a
time, such as instances of HttpSession, may be available to multiple servlets, including those
that implement SingleThreadModel, at any particular time.

(Servlet 2.2 specs on servlet instances)
-anthony
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: servlet pool