The Workshop is designed to help you review what you have learned, and help you to further increase your understanding of the material covered in this hour.
What methods of the JSP implicit object session are used to store, retrieve, and delete objects in a session?
What do you have to do so that you can use sessions in a JSP?
What causes a session to expire?
When a session expires, how can I release resources that are associated with it?
setAttribute, getAttribute, and removeAttribute are the methods used. Methods of the same name are used with the application object to store attributes that have application scope.
A JSP that participates in sessions must use a Page Directive Attribute session whose value is true.
Sessions expire because they are invalidated by a container or by an application. Sessions are often invalidated by a container after a specific amount of time or when the container discovers that a user has done something to invalidate a session, such as close their browser.
Objects that need to know when a session they are attached to expires can implement the HttpSessionListener interface and make the appropriate changes to the application deployment descriptor.
Write a JSP that asks a user for their name and a favorite activity. Store the information in an object that is attached to a session. Create another JSP that allows the user to review and change the stored information.
Modify the application you wrote above to provide the option to "publish" their information to the application scope. Add another JSP that shows all of the information for every user who has published their data.