Implicit JSP Objects

When you use scripting elements in a JSP page, you always have access to a number of objects (listed in Table 6.1) that the JSP container makes available. These are called implicit objects. These objects are instances of classes defined by the servlet and JSP specifications. Appendix B, contains complete descriptions of all methods for each class, and we will cover them in more detail as we move through the book. However, I want to briefly introduce them here, as they are used in a number of examples throughout this book.

Table 6-1. Implicit JSP Objects

Variable Name

Java Type

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

Here is some more information about each of these implicit objects:

request

The request object is an instance of the class named javax.servlet.http.HttpServletRequest. This object provides methods that let you access all the information that’s available about the current request, such as request parameters, attributes, headers, and cookies. We use the request object in a couple of examples later in this chapter.

response

The response object represents the current response message. It’s an instance of the javax.servlet.http.HttpServletResponse ...

Get Java Server Pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.