Implicit objects

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.

References to an object created in script are stored in the pageContext, request, session, or application implicit object, according to the object’s scope.

Table 8-5: Implicit objects for a JSP target

Implicit object

Description

Scope

request

The request triggering the servlet invocation.

Request

response

The response to the request that triggered the servlet invocation.

Page

pageContext

The page context for this JSP.

Page

session

The session object created for the requesting client (if any).

Session

application

The servlet context obtained from the servlet configuration, as in the call getservletConfig().getContext().

Application

out

An object that writes to the output stream.

Page

config

The ServletConfig instance 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.

Page

exception

The uncaught Throwable exception that caused the error page to be invoked.

Page

Implicit objects display on the Language tab page in the System Tree.

Shown is the Language tab page in the System Tree with folders expanded for Object Models, Server, and then J S P Implicit Objects. All of the JSP Implicit Objects display within their folder.

Implicit objects other than the exception object are always available within scriptlets and expressions. If the JSP is an error page (the page directive’s isErrorPage attribute is set to true), the exception implicit object is also available.

You can often use an implicit object or a Web Target object model wrapper class to obtain the same functionality. For example, calling out.println in a server-side event is equivalent to calling psDocument.Write.

For more information about the exception implicit object, see “Error handling”. For more information about server-side events, see “Writing server scripts”.