aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes are request attributes and session attributes thread safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "are request attributes and session attributes thread safe?" Watch "are request attributes and session attributes thread safe?" New topic
Author

are request attributes and session attributes thread safe?

raymond yadao
Ranch Hand

Joined: Jan 29, 2001
Posts: 88
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

Joined: Jun 29, 2003
Posts: 285
request scope is thread safe but the session is not.


The secret to creativity is knowing how to hide your sources.
Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
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....


SCJP2, SCWCD
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: are request attributes and session attributes thread safe?
 
Similar Threads
Thread safe servlets
Thread Safe
Static Variable in Servlet
How does servlet stay active ?
MVC Pattern doubt