SRV.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 being part of a distributable web application, the container may instantiate multiple instances of that servlet in each VM of the container.

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



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net