Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is Single Threaded Model in Servlets? Explain this
with an example?

Answer Posted / anjali nema

Typically, a servlet class is instantiated the first time
it is invoked. The same instance will be used over several
client requests, so all members that are declared in that
servlet are shared accross clients. That is what is meant
by multi threaded model, multiple clients that access the
same instance.

There are situations where you want to protect your servlet
member variables from being modified by different clients.
In this case, you can have your servlet implement the
marker interface SingleThreadModel. Every time a client
makes a request to a servlet that implements this
interface, the engine will create a new instance of the
servlet. For performance reasons, the engine can also
maintain a instance pool, handing out instances as they are
needed. Or it could also serialize client requests,
executing a single request.

Is This Answer Correct ?    38 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can an existing session be invalidated?

1173


Which event is fired at the time of session creation and destroy?

1395


Can you call a jsp from the servlet?

1023


Why do we need servlet filter?

1060


What's the architecture of a servlet package?

1058


What are all the protocols supported by httpservlet?

1284


What are the types of servlets? Explain

1267


What is the requirement of servlet config and servlet context implemented and how are they implemented?

1006


Why doesn’t a servlet include main()? How does it work?

1163


Should I override the service() method?

1094


How can you run a servlet program?

1086


What is the difference between Difference between doGet() and doPost()?

1302


Why is a constructor needed in a servlet even if we use the init method?

1140


What is api in servlet?

1024


How can we invoke another servlet in a different application?

1217