What is the use of managed-bean-scope flag in the faces-config.xml (JSF)?


What is the use of managed-bean-scope flag in the faces-config.xml in ?


Managed bean scope defines the lifespan of managed bean. There are 4 possible values: “application”, “session”, “request” and “none”.

The request scope bean is short-lived. If the bean is needed and created when server receives an HTTP request, it will be destroyed as soon as the response is sent back to the client.

The session scope bean persists from the time that a session is established until session termination. A session terminates if the web application invalidate session manually, or if it times out (this timeout period is defined in your servlet container configuration, and usually lasts few minutes). This means that after your bean is created, it will last for some time and between requests. For example, in a shopping application, you want the server to remember the contents of the shopping cart for some user across several pages.

Application scope beans are persisted for the duration of the application.

“None” is not exactly a scope, and is used for beans that are used only as managed properties of another beans.

(Visited 45 times, 1 visits today)

Leave a comment

Your email address will not be published. Required fields are marked *