page

Beans with page scope are accessible only within the page where they were created. References to an object with page scope will be released when the response is sent back to the client or the request is forwarded to another resource. Objects with page scope are stored in the pageContext. A bean with page scope is most often used for single instance calculations or transactions.

An example of using the Counter bean with page scope can be found in Listing 11.2.

Code Listing 11.2. PageBean.jsp
 <%@ page errorPage="errorpage.jsp" %> <!-- Instantiate the Counter bean with an id of "counter" --> <jsp:useBean id="counter" scope="page" class="Counter" /> <html> <head> <title>Page Bean Example</title> </head> <body> <H3>Page Bean Example</H3> <center><b>The ...

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.