O'Reilly logo

JavaServer Pages, Second Edition by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implicit JSP Scripting Objects

Scripting elements can use predefined variables that the container assigns as references to implicit objects (Table 15-1) to access request and application data. These objects are instances of classes defined by the servlet and JSP specifications. Appendix D contains complete descriptions of all methods for each class, and they are briefly introduced here and used in a number of examples in this chapter.

Table 15-1. Implicit JSP objects

Variable name

Java type

application
javax.servlet.ServletContext
config
javax.servlet.ServletConfig
exception
java.lang.Throwable
out
javax.servlet.jsp.JspWriter
page
java.lang.Object
pageContext
javax.servlet.jsp.PageContext
request
javax.servlet.http.HttpServletRequest
response
javax.servlet.http.HttpServletResponse
session
javax.servlet.http.HttpSession

These objects provide access to the same information (and more) as the implicit variables you can use in EL expressions, but it’s not a one-to-one match:

pageContext

The pageContext variable contains a reference to an instance of the class named javax.servlet.jsp.PageContext. It provides methods for accessing references to all the other objects and attributes for holding data that is shared between components in the same page. It’s the same object that you can access with the ${pageContext} EL expression. Attribute values for this object represent the page scope; they are the same objects as are available to the EL world as a Map represented ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required