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
Which event is fired at the time of project deployment and undeployment?
Describe some assignments that are executed by servlet container?
How do I use cookies to store session state on the client?
What do you mean by request dispatcher in servlet? Also explain its methods.
Explain the servlet filter.
What are the functions of Servlet container?
What is the difference between the include() and forward() methods?
Difference between GET and POST?
How can you use a servlet to generate a plain text instead of html?
What's the difference between servlets and applets?
Define the servlet mapping.
Is java servlet still used?
What must be implemented by all servlets?
What do you mean by servlet context?
Why HttpServlet class is declared abstract?