Java Reference
In-Depth Information
config
Similar to the
application
object, the
config
object provides a reference to the
ServletConfig
interface of the web application. The
ServletConfig
interface is used to provide access to any
initialization parameters that have been configured for the JSP page via the deployment descriptor
of the web application. The
config
object provides the JSP developer with access to the
ServletConfig
object.
exception
The implicit
exception
object is available to JSP to handle the error conditions and report the
runtime exceptions using the
errorPage
page directive.
out
The implicit
out
object represents an instance of the
JspWriter
class that is used to write character
data to the response stream.
page
The JSP implicit
page
object is an instance of the
Object
class and represents the current JSP page.
pageContext
A
pageContext
provides context information by providing access to all the namespaces associated
with a JSP page and to several page attributes. Also, it contains the reference to implicit objects.
request
The
request
object is an instance of the
javax.servlet.http.HttpServletRequest
interface.
It represents the client request. The
request
implicit object is generally used to get request
parameters, request attributes, header information, and query string values.
response
The implicit
response
object is an instance of the
javax.servlet.http.HttpServletResponse
interface and represents the response to be given to the client. The implicit
response
object is
generally used to set the response content type, add cookies, and redirect the response.
session
The JSP implicit
session
object is an instance of a Java class that implements the
javax.servlet.http.HttpSession
interface. It is used to store session state for a client.
Listing 2-20 illustrates the usage of the often-used implicit objects. First it shows the common task
of setting a
book
attribute in the request, session, and application scopes in a servlet. Then it shows
their JSP equivalents.