session

Beans with session scope are accessible only within pages processing requests that are in the same session as the one in which the bean was created. It is illegal to define an object with session scope from within a page whose page directive has an attribute session=false. References to the session objects are released after their associated sessions expire. Objects with session scope are stored in the session object associated with the page.

Beans that use session scope are most often used when there is a need to share information between requests for a single client. A common application using bean scope is a shopping cart, which we cover in Chapter 13, "JSP and a Shopping Cart." For our example, we use the Counter bean and two almost ...

Get Pure Java Server Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.