| Author |
can same servlet have multiple instance in container
|
Pratibha Malhotra
Ranch Hand
Joined: Dec 21, 2003
Posts: 199
|
|
Hi Single thread model is used to enforce one request accessing servlet at a time . Servlet Api says, container may decide to have multiple instances of servlet if SingleThreadModel is implemented. can we have more than one instance of a servlet in a container
|
~ Pratibha Malhotra<br /> <br />Sun Certified Java Programmer<br />SCEA 1.4 (In Progress)<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />"Many of life's failures are people who did not realize how close they were to success when they gave up!!"
|
 |
Kunaal A Trehan
Ranch Hand
Joined: Feb 04, 2004
Posts: 63
|
|
Hi Yes we can have more than one instance for the servlet. Rgds Kunal
|
 |
Kaustubh Patil
Ranch Hand
Joined: Aug 13, 2001
Posts: 164
|
|
A servlet can have more than one instances in the JVM. The number might be configured. SingleThreadedModel indicats that at a time only one request will be allowed to access the one instance's service() method. Effectively it means that the service() method is synchronized. Note : There might be more than one instances in SingleThreadedModel and more than one requests serviced. But only one request per instance.
|
Kaustubh. Mumbai, India.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
|
Note that SingleThreadedModel is deprecated and should not be used. Just write your servlets to be thread-safe and get on with it.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12266
|
|
To quote from the Servlet API 2.3 - section 2.2 "For a servlet not hosted in a distributed environment (the default) the servlet must use only one instance per servlet declaration." It then goes on to discuss the exception of the SingleThreadModel. You really should get a copy of the API to answer these questions - it is the final authority. Bill
|
 |
 |
|
|
subject: can same servlet have multiple instance in container
|
|
|