Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response and Request Object threadsafe? Why?

 
Louis Duquesne
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to two questions in the "WGS-PREX-J080B: ePractice Exam Sun[TM] Certified Web Component Developer J2EE" (Objective 7), the Response object is not thread-safe.
I fail to understand why (isn't this a parameter and thus a "local" variable?).
Would someone care to explain? Is the Request object thread-safe, if so why the difference?
Thanks
Louis
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a local variable, but check out what the Servlet specification has to say about these objects:
SRV.2.3.3.3 Thread Safety

Implementations of the request and response objects are not guaranteed to be thread
safe. This means that they should only be used within the scope of the request
handling thread.

References to the request and response objects must not be given to objects
executing in other threads as the resulting behavior may be nondeterministic.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duquesne,

Take another glance at our naming policy ( http://www.javaranch.com/name.jsp ), and update your display name (or re-register).

Thanks, and welcome to JavaRanch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic