This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes HttpSession concept Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSession concept" Watch "HttpSession concept" New topic
Author

HttpSession concept

nippon ask
Greenhorn

Joined: Nov 03, 2003
Posts: 2
Hi, i'm getting weird things on my user sessions, so i was wondering...
...Is the HttpSession thread-safe?
I'm having users objects 'setted' on other users sessions, so, may it be that i need to enclose the code in a 'synchronized' block?
I'll appreciate any help...
R
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Sessions are not automatically Thread-safe, but should be unique to individual users. Confusion of objects between users is almost certainly due to bad program architecture and will not be helped by synchronization.
The only time you should have to worry about synchronizing access to objects in sessions is when you have the possibility of processing multiple requests from the same user "at the same time" - for example with frames or where images are being generated.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSession concept