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

HFSJ Mock Exam

 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By making doGet() of HttpServlet synchronized it will make ServletRequest Attribute Thread Safe.

True or false

Thanks
Srividhya
 
Paul Brabban
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Attributes of ServletRequest are thread-safe anyway (how would you access an attribute in request scope from another thread?) so no, synchronizing doGet won't make any difference.

Cheers,

Paul
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul This statement is given as true in the HFSJ mock exam. So just wanted to clarify.

Srividhya
 
Baddy Davay
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that should be true.The reason behind that is ,request attribute can be accessed only from the doXXX methods ,So all the requests mapped to the doXX methods with doXXX methods synchronized obviosly by the Java Rule makes the method thread safe ,and hence makes the attributed accessed or updated as well thread safe.
Correct me if I am wrong
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic