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
What is the difference between portlet and servlet?
Write all the phases defined in servlet life cycle?
What are the life-cycle methods for a servlet?
Differentiate between the print writer and servlet output stream?
What exactly is a servlet?
Explain web container.
What are the different ways we can maintain state between requests?
Explain the servlet filter.
What is the main purpose of java servlets?
If my browser does not support cookie, and my server sends a cookie instance what will happen?
Which event is fired at the time of session creation and destroy?
Servlet is pure java object or not?
What do you understand by mime type?
What are the difference between RMI and Servlets?
Can you create a deadlock condition on a servlet?