The implicit JSP objects
Http request originally sent to server
Http response to request
Session object associated with the
above request and response
Holds references to other objects that
more than one user may access,
such as a database link
Object that writes to the response
Contains information about a runtime
error and is available only on
Encapsulates the page context
ServletConfi g object for this JSP
The this object reference in this JSP
ServletContext is an interface implemented by each servlet engine that provides
a servlet with methods that allow it to fi nd out about its environment (independent
of any individual session). This interface has two methods that mirror the Session
class's methods getAttribute and setAttribute . The two methods have names, argu-
ments and return types that are identical to those of the corresponding Session meth-
ods. The signatures for these methods are repeated below.
public Object getAttribute(String <name>)
public void setAttribute(String <name>,
As shown in Table 9.1 , the implicit object application is the ServletContext
object that is created automatically for a JSP and allows the programmer to retrieve
and set environment-level properties via the two methods above.
In the examples below, note the need for typecasting with getAttribute , since it
returns an Object reference.
String userName =
Float balanceObject =
setAttribute("total", new Integer(0));
Other methods of object application that are sometimes useful are listed below
and have purposes that are self-evident.