Java Reference
In-Depth Information
F IGURE 17.1
The output from PageBean.jsp .
request Scope
Beans with request scope are accessible only within pages processing the same request in
which the object was created. References to the object will be released after the request is
processed completely. If the request is forwarded to another resource in the same runtime then
the object is still in scope. References to objects with request scope are stored in the request
object. Objects that have request scope are most often used when you need to share informa-
tion between resources that is only pertinent for the current request.
As an example of a bean with request scope, you'll create an instance of the Counter bean
and forward it to another resource. Listing 17.3 contains the JSP that creates your bean and
forwards it to a second JSP.
L ISTING 17.3
RequestBean1.jsp
<%@ page errorPage=”errorpage.jsp” %>
<!-- Instantiate the Counter bean with an id of “counter” -->
<jsp:useBean id=”counter” scope=”request” class=”Counter” />
Search WWH ::




Custom Search