wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Are request, response objects not thread safe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Are request, response objects not thread safe" Watch "Are request, response objects not thread safe" New topic
Author

Are request, response objects not thread safe

Vijay Bharghav bheemineni
Greenhorn

Joined: Aug 31, 2005
Posts: 29
Hi All,

Till today I was thinking "request" and "response" objects are thread safe, because Servlet creates these object for every new request. Even "Head First" series says "request" and "response" objects are thread safe. But today when I am reading Servlet Specs "SRV2.3.4", I found that they are not thread safe.

Please comment.

Regards,
Vijay Bheemineni.
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
Vijay,

The thread-safety HFJS etc. are talking about, refers to the multiple threads the container creates (one for each request).

The specs refer to the scenario where the thread of one request, creates another thread. If that new thread (that is not created by the container) accesses the Request or Response object from the first thread, at the same time the first thread does, then problems can occur.


SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Vijay Bharghav bheemineni
Greenhorn

Joined: Aug 31, 2005
Posts: 29
Thanks Jan for your explanation, I got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are request, response objects not thread safe