12. What are the default objects provided by JSP container?

Implicit objects let developers access container-provided services and resources. These objects are defined as implicit because you do not have to explicitly declare them. They are defined in every JSP page and used behind the scenes by the container whether you declare them or not — although you cannot redeclare them. Because implicit objects are declared automatically, we need only use the reference variable associated with a given object to begin calling methods on it.

The nine implicit objects, with a brief description of each one’s function, are:

  • Application is the broadest context state available. It allows the JSP page’s servlet and any Web components contained in the same application to share information.
  • Config allows initialization data to be passed to a JSP page’s servlet.
  • Exception houses exception data to be accessed only by designated JSP “error pages.”
  • Out provides access to the servlet’s output stream.
  • Page is the instance of the JSP page’s servlet processing the current request. Not typically used by JSP page authors.
  • PageContext is the context for the JSP page itself. It provides a single API to manage the various scoped attributes. This API is used extensively when implementing JSP custom tag handlers.
  • Request provides access to HTTP request data, as well as providing a context for associating request-specific data.
  • Response enables direct access to the HTTPServletResponse object and is rarely used by JSP authors.
  • Session is perhaps the most commonly used of the state management contexts. The concept of a “session” is that of a single user interacting with a Web application over several requests.

Although some implicit objects address a single function, several of them provide multiple categories of functionality. In the sections that follow, we’ll review implicit objects according to functional categories:

  • Session management: application, session, request, pageContext
  • Flow control: application, config, pageContext, request, session
  • Logging and exceptions: application, config, exception, pageContext, request, session
  • Input/output control: request, response, out
  • Initialization parameters: config
Advertisements

3 Responses

  1. In jsp which is the default object which is not implicit

  2. page is the default

  3. Nice explanation!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: