Follow Our FB Page << CircleMedia.in >> 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?

226


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

234


Write a hello world program using servlets.

219


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

231


how to link html file to sevlet file.one 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

1625






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

197


What are the uses of servlet

245


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

232


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

201


How the servlet is loaded?

224


What are the various ways of session supervision in servlets?

198


Can a jsp be called using a servlet?

223


Explain the different ways for servlet authentication?

190


How servlets are deployed in java?

205


What is Servlet API used for connecting database?

241