Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is request and resonse objects are thread safe?

 
sureshreddy puli
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me about the thread safe of request and response objects.
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally the objects are thread safe, however stateful. So, one thread can initiate reading of data, and another thread trying to do the same can end up with meeting EOS.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each request runs in a seperate thread, so the particular objects are thread safe. however, session and context attributes are NOT thread safe, so yuo have to be careful when you are working with them.
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request and Response objects are local to their own methods and not shared between servlet threads, thus they are by nature, thread safe. The only requirement from the servlet specification is that you should not keep references to them after the method ends, for example put them in class level members, put in session, etc; because the behavior of Request and Response after the method returned are undefined.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic