Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Thread Safe Servlet

 
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
 
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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic