aspose file tools*
The moose likes JSF and the fly likes Are managed-beans shared? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Are managed-beans shared?" Watch "Are managed-beans shared?" New topic
Author

Are managed-beans shared?

Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92
Hi, fellas

I was thinking about some things, and I am not sure about how JSF manages my beans. I know that a managed-bean stored in session scope is shared throughout all requests in that user's session, but what about request scope managed-beans? Are they pooled or even shared accross multiple requests? I need to know if it is safe to use instance variables in my backing beans. I know it does not work for Servlets and Struts but, hey, this is JSF! Clarifying is very appreciated


Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
The simplest thing to do would be to place a System.out.println in your bean's constructor and find out... And what you would find is that request scope beans are not reused -- they are constructed when needed. These beans are usually there to back a HTML FORM, so they are cheap to construct -- there should be no need to "optimize" this by pooling or reuse -- that would only slow things down!


There is no emoticon for what I am feeling!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are managed-beans shared?
 
Similar Threads
Managed Bean as service locator
Question about bean creating
EJB3 + JSF2
Need to understand the Request Scope
Set Managed Bean property (value) without user interaction