Java Reference
In-Depth Information
F
IGURE
15.1
Output from
UseRequest.jsp
.
The
pageContext
Object
The
pageContext
object provides access to the namespaces associated with a JSP page. It also
provides accessors to several other JSP implicit objects.
An instance of an implementation-dependent
pageContext
is created by a JSP implementation
class at the beginning of the generated servlet's
_jspService()
method. It is created through
an implementation-dependent
JspFactory
. An example of the
pageContext
object's creation
and its use in the creation of other implicit objects is shown in the following code snippet:
pageContext = _jspxFactory.getPageContext(this, request, response,
“errorpage.jsp”, true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
15
You can see by examining the previous code snippet that the
pageContext
is used often in the
generated servlet. However it is not often used directly in a JavaServer page. The exception to
this is in the creation of custom tags, which we will examine in Chapter 19, “Custom JSP Tag
Libraries.”