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 attributes and session attributes thread safe?

 
raymond yadao
Ranch Hand
Posts: 88
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic