Keeping Track of Multiple Guests
You've been using the variable currentGuest in the Main component to hold the information entered by the user. You'll need another variable (an array) to store the list of all the guests who have registered.Before doing this, it is important to understand the scope and life span of variables in WebObjects:
- Component variables, such as currentGuest, exist for the lifetime of the component. These variables are defined in the component (in this case, Main.java) and are accessible only by its methods. Each user that uses a component gets a separate instance of the variable.
- Session variables exist for the lifetime of one user's session and are accessible by all code in the session. They are defined in Session.java. An instance of each session variable is created for each user.
- Application variables live as long as the application does and are accessible by all code in the application. They are defined in Application.java. A single instance of an application variable is shared by all users of the application.
Table of Contents Next Section