File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Are request, response objects not thread safe

 
Vijay Bharghav bheemineni
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vijay Bharghav bheemineni
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jan for your explanation, I got it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic