Follow Our FB Page << >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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

Whats the advantages using servlets over using CGI?


What is a web application and what is it’s directory structure?


Write a hello world program using servlets.


How can we refresh automatically when new data has entered the database?


how to link html file to sevlet name is textbox,c&c++ is cheakbox,bc&mca is radio button and one submit buttonis ok why in this programme use in servelt file


Can you refresh servlet in client and server-side automatically?


What are the uses of servlet


What is meant by Servlet? What are the parameters of service method?


What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?


How the servlet is loaded?


What are the various ways of session supervision in servlets?


Can a jsp be called using a servlet?


Explain the different ways for servlet authentication?


How servlets are deployed in java?


What is Servlet API used for connecting database?