This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Servlets" Watch "Servlets" New topic
Author

Servlets

prathima sampelly
Greenhorn

Joined: Nov 05, 2006
Posts: 2
Are servlets&jsp s thread safe by default? if not how to make it thread safe
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3829
Originally posted by prathima sampelly:
Are servlets&jsp s thread safe by default? if not how to make it thread safe


No. The one you are talking about is the case of Single Thread Model.

In general, container creates different thread for each request and all threads execute at the same time.
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

Servlet and JSP is not Thread Safe By Dafeult.

If You want to make Servlet Thread Safe, you need to implement SingleThreadModel interface.But this is deprecated now. It not advisable to use this.

If you want make JSP thread safe, make page attribute isThreadSafe="true". but servlet class generated from JSP implements SingleThreadModel interface. So, this too is not advisable to do.

HTH,


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12268
    
    1
This is too complex a question to handle in a simple forum response. Go read a servlet tutorial, then browse past discussions. You are not the first person to ask this question and there is no need for us to repeat the many discussions that have resulted.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Servlets
 
Similar Threads
How container manage to serve servlet to number of request
How beans in EJB3.0 are threadsafe?
Doget, Dopost
Servlets thread safe?...
Thread-safe servlets on 081 exam???