How to make servlet thread safe?

Answer Posted / shakir khan

There are situations where we want to protect your servlet
member variables from being modified by different
clients.In this case you can have your servlet by
implementing the marker interface SigleThreadModel.

Everytime a client makes request to a servlet by
implementing this interface,servlet engine will create a
new instance of servlet.

For performance reason,servlet engine can also maintain a
instance pool,handing out instances as they are needed.Or
it could also serialize client request executing one after
another.

Is This Answer Correct ?    49 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between Servlets and Applets?

543


What do you mean by cgi?

529


What do you mean by httpservlet and how it is different from the genericservlet?

536


What do you mean by chaining in servlet?

570


What do you mean by interservlet communication?

580






Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?

775


What are the difference between RMI and Servlets?

1049


What is the difference between servlet and jsp?

596


What is the element?

585


What are the steps that are required to handle the multi-threading?

593


What is a deployment descriptor?

595


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

539


Describe servlet?

576


What is servlet lazy loading?

692


What is difference between cookies and httpsession?

544