File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 12675
    
    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


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets
 
Similar Threads
Servlets thread safe?...
Doget, Dopost
How beans in EJB3.0 are threadsafe?
How container manage to serve servlet to number of request
Thread-safe servlets on 081 exam???