How to make servlet thread safe?

Answer Posted / tulasi vani

There are two different ways of making a servlet thread
safe namely

1.By implementing SingleThreadModel.

By implementing a SingleThreadModel it will be possible to
create a Thread safe servlet.There can only be one user at
a given point of time.

2.Synchornize the part of sensitive code.

We can allow a single user at a given point of time by
making that part of the code which is sensitive as
synchronized.

Is This Answer Correct ?    127 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the features added in Servlet 2.5?

779


What do you mean by scope object and what are its types?

576


How to notify an object in session when session is invalidated or timed-out?

642


What is the importance of init() method in Servlet ?

596


Explain the architechure of a servlet?

613






What is the need of session tracking in web application?

591


Which are the different ways you can communicate between servlets?

536


What is the procedure of invoking different servlet in a different application?

569


What is servlet name in web xml?

564


What is the use of httpservletrequestwrapper?

598


Why is Servlet so popular?

618


Can we fetch the attributes related to a servlet on a different servlet?

650


What is Servlets and explain the advantages of Servlet life cycle?

592


What is difference between cookies and httpsession?

552


If a servlet is not properly initialized, what exception may be thrown?

633