This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets

 
prathima sampelly
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are servlets&jsp s thread safe by default? if not how to make it thread safe
 
ankur rathi
Ranch Hand
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 502
Java jQuery Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic