Understanding Scope and Managed Beans
By dananourie on Nov 15, 2007
In developing applications, either for the desktop or the Internet, you need to get a good understanding of the concepts of scope, which is the lifespan an object that may last just for that page, for an entire session, or for the duration of an application. In addition, managed beans can save you code time, and is necessary for dealing with the data of your application. A managed bean is a JavaBeans object that stores data in either request scope, session scope, or application scope.
To understand these concepts fully, read the following tutorial and create the sample application.
In this tutorial, you use the NetBeans Visual Web Pack to create an application that demonstrates how to use application, session, and request scopes to manage your application's objects. Scope is the availability (or context) of an object and its intended life span in a web application.
The web application that you create in this tutorial uses an object in application scope to tally votes, and uses an object in session scope to ensure that a user votes only once per session. The application uses a request scope object to display the time that the user submitted the vote. The time is stored in request scope, because the application does not need the value after the response is sent to the client browser.
- About Scopes
- Adding Properties to Managed Beans
- Creating the Start Page
- Creating the Results Page
- Specifying Page Navigation
- Running the Application
- Doing More