Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

are request attributes and session attributes thread safe?  RSS feed

 
raymond yadao
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. are request attributes and multiple attributes thread safe in multiple servlets ( no implementation of single thread model and synchronization)?
thanks.
raymond
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request scope is thread safe but the session is not.
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i absolutely agree to faisal ...
Request scope is thread safe (unless u don't create thread from within the doXXX() method which has been called and try to access the request scope. However for exam request scope is always safe ...
But session is never safe....
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veenu,
sessions cane be safe if you synchronize on the session object, as in:
synchronize(session) {
// all the session get and set
}
of course, there will be performance implications of doing this.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!