• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Saftey in JSF

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Open a new Browser window (eq. Mozilla) which shares the session cookies

or the double submit problem.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic