This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Thread Saftey in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Thread Saftey in JSF " Watch "Thread Saftey in JSF " New topic
Author

Thread Saftey in JSF

Prem Khan
Ranch Hand

Joined: May 30, 2005
Posts: 189
I was reading my book "JSF in action" by Kito mann, and it says you must watch out for session scope managed beans to be thread safe. Because other threads can manuipate the values in the same bean.

This doesnt make any sence to me, I have many users and iv never had any probblem with my session scope beans. I thought each User has there own instance of the bean.

Do you all use session scope beacuse I do
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

I'ts not that you have to be careful between users. What that means is that say you put a bean in the session and then the same user spawns several threads that can manipulate that session object. I say again, the same user. That is when you have to be careful.

With that being said, I rarely have a managed bean in session scope, though I'll have some objects in session that are used by various managed beans.
Prem Khan
Ranch Hand

Joined: May 30, 2005
Posts: 189
So how can one user spawn several threads ?

Is one user really one instance of a web browser ?
If thats the case I dont see how one user could spawn more than one
George Daswani
Greenhorn

Joined: Sep 28, 2005
Posts: 12
Open a new Browser window (eq. Mozilla) which shares the session cookies

or the double submit problem.
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

Originally posted by Shawn DeSarkar:
So how can one user spawn several threads ?

Is one user really one instance of a web browser ?
If thats the case I dont see how one user could spawn more than one


For the most part, you probably don't need to worry about thread safety and managed beans. It's just always a good idea to keep it in the back of your mind.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Saftey in JSF
 
Similar Threads
JSF navigation questions
How can we use <jsp:scriptlet /> tag in jspx file that uses faclets
Need to understand the Request Scope
JSF session management
Spring web flow, JSF and managedbean in servlet