File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Managed ben doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Managed ben doubt" Watch "Managed ben doubt" New topic

Managed ben doubt

Maya Pillai
Ranch Hand

Joined: Jul 17, 2008
Posts: 60

In my application all the managed beans are in scope session. Will it cause any performance issue? Do we need to serialize this bean objects.

Can anyone tell me the best approach. I am using jsf1.2

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Well yes. The data must be stored somewhere, in memory or on disk.
Only data that needs to be stored you should store and for other classes you should make them stateless.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

If you have a choice, you should use request scope instead of session scope. That's because the server has to keep objects on a long-term basis, and the more objects you're keeping, the more RAM it eats up. Request scope objects exist only while a request is active, so they take a smaller "bite",

However, JSF does tend to force you to use session scope in a lot of cases where you wouldn't otherwise have to. JSF2 eases some of this by adding View scope.

Session scope objects (including non-JSF session-scope) objects need to be serializable. Some appservers will get very annoyed if you don't declare session objects as serializable. That's because if the appserver needs to free up memory by "paging" objects out or if the appserver needs to transfer the session to another VM, the data must be serialized/deserialized.

Of course, if you say something's serializable, you must mean it. Otherwise, if the data goes through serialization/deserialization, the deserialized copy of the object may be missing critical information.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Managed ben doubt
It's not a secret anymore!