JSP implicit objects

This section provide you extensive knowledge about the various aspects of JSP implicit objects, how its created and how it works for developer.

JSP implicit objects

In this tutorial section, you will learn about the various aspects of JSP implicit objects. There are 9 JSP implicit objects, which are created by the web container from available to all the JSP pages.

In fact, the implicit objects in JSP are those objects, which are created by the container automatically. One important thing is that the container makes them available to the developers, as latter do not need to create theses facts explicitly. These JSP implicit objects are created by container and it translates these pages to servlet source obviously it helps developers. The code turned the class level and hence you can’t use them in JSP declaration.

However one can use the JSP implicit objects directly in scriptlets, which goes in service method. Although we can’t use these content in JSP implicit objects as those code will meet as class level.

There are nine implicit objects. Here is the list of all the implicit objects:

Object Class
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.ServletRequest
response javax.servlet.ServletResponse
session javax.servlet.http.HttpSession

Application: In the JSP implicit objects, these are such objects, which has an application scope. It has an instance of a class that implements javaz.servlet.servlet context interface. These are available at the widest context level, that allows sharing the same information.

Config: These are such kind of object which implements javax.servlet.ServletCongig interface, to provide the facility to obtain the parameter information. It also has a page scope and is an instance of javax.servlet.ServletConfig class. Config object allows passing the initialization data to a JSP page's servlet.

Exception: This kind of object has a page scope and is an instance of java.lang.Throwable class. It is an instance to handle exceptions in a JSP. It also represents an error page.

Out: This kind of object provides us to access the servlet's output stream and has a page scope. It is the instance of javax.servlet.jsp.JspWriter class. The out implicit provides the output stream that enable access to the servlet's output stream.

Page: This is an instance of the JSP page's servlet class that processes the current request. Page object represents the current page that is used to call the methods defined by the translated servlet class.

Pagecontext: It is another PageContext page with context for the JSP page itself that provides a single API to manage the various scoped attributes. This API is extensively used if we are implementing JSP custom tag handlers. PageContext also provides access to several page attributes like including some static or dynamic resource.

Request: Request object has a request scope that is used to access the HTTP request data, and also provides a context to associate the request-specific data. This object implements javax.servlet.ServletRequest interface. It uses the getParameter() method to access the request parameter. The container passes this object to the _jspService() method.

Response: This object has a page scope that allows direct access to the HTTPServletResponse class object. Response object is an instance of the classes that implements the javax.servlet.ServletResponse class. Container generates to this object and passes to the _jspService() method as a parameter.

Session: It is the object that has a session scope and as an instance of javax.servlet.http.HttpSession class. It seems that it is the most commonly used object to manage the state contexts. This object persist information across multiple user connection.


JSP Tutorials

JSP Implicit Objects

JSP implicit object "response"

Implicit Objects In JSP

JSP Implicit Objects

JSP implicit object "pagecontext"

JSP implicit object "application"

JSP implicit object out

JSP Implicit object "session"