This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
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: 3830
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: 12761
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets
 
Similar Threads
Thread-safe servlets on 081 exam???
How container manage to serve servlet to number of request
Servlets thread safe?...
How beans in EJB3.0 are threadsafe?
Doget, Dopost