To see how it works, copy both of these JSPs to the < SERVER_ROOT >/djs/ directory and open
your browser to the following URL:
http:// localhost /djs/RequestBean1.jsp
You will see a page similar to Figure 17.2.
F IGURE 17.2
The output from RequestBean1.jsp .
You can reload the page several times, but the result will always be the same. The second JSP
will print the current value of the count property as 11 . This is because the instance of the
bean only lasts as long as the request.
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