Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Safe Servlet

 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we create a thread safe JSP ?
A <%@ page isThreadSafe = "true" %>
B <%@ page implements="SingleThreadModel" %>
C <%@ page isThreadSafe="false" %>
D <%@ page extends="SingleThreadModel" %>

To my opinion Answer A is correct ,means application is thread safe and doesnot implement SingleThreadModel.

Mock Exam Explaination
Answer C

The isThreadSafe attribute of page directive defines whether the generated servlet needs to implement SingleThreadModel. The default value for isThreadSage attribute is true and if false, the generated servlet will implement SingleThreadModel.


Although the explaination is right but answer is wrong.
Please share your views
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think this question is pertaining to old exam. Now the singleThread model is deprecated, as it give false impression that the severlet is thread safe. By making isThreadSafe attribute to false, it means that you are asking the container to make my servlet thread safe.

Thanks
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But in page directive we still have the isThreadSafe attribute, so if we make it

<%@ page isThreadSafe = "true" %>

So I think it would mean page is thread safe and doesnot implement SingleThread Model, as in above my 1st option A.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Yes, you are correct. By default the isThreadSafe is true telling the container that I made my servlet threadsafe so don't implemant SingleThread Model for this Servlet.

Thanks
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Narendra
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic