Chapter 24 JavaServer Pages
Objects and scopes
When a JSP page processes a request, it has access to a set
of implicit objects, each of which is associated with a given scope.
Other objects can be created in scripts. These created objects have
a scope attribute that defines where the reference to that object
is created and removed.
Scopes
There are four scopes:
- Page - accessible
only in the page in which the object is created. Released when the
response is returned or the request forwarded.
- Request - accessible from pages processing
the request in which the object is created. Released when the request
has been processed.
- Session - accessible from pages processing
requests in the same session in which the object is created. Released
when the session ends.
- Application - accessible from pages processing
requests in the same application in which the object is created.
Released when the runtime environment reclaims the ServletContext.
References to the object are stored in the PageContext, Request,
Session, or Application object, according to the object's
scope.
Implicit objects
The following implicit objects are always available within
scriptlets and expressions:
- request - the
request triggering the service invocation.
- response - the response to the request.
- pageContext - the page context for this
JSP page.
- session - the session object created for
the requesting client (if any).
- application - the servlet context obtained
from the servlet configuration, as in the call getservletConfig().getContext().
- out - an object that writes to the output
stream.
- config - the ServletConfig for this JSP
page.
- page - the instance of this page's
implementation class that is processing the current request. A synonym
for this
when the programming language is Java.
For information about the scope and type of each implicit
object, see the JavaServer Pages Syntax Card http://java.sun.com/products/jsp/syntax.pdf
.
The exception implicit object
If the JSP page is an error page (the page directive's
isErrorPage attribute is set to true), the following implicit object
is also available:
- exception - the
uncaught Throwable that resulted in the error page being invoked.
For more information, see "Error handling".
Copyright © 2000 Sybase, Inc. All rights reserved.
|
|