JSP container provides a list of objects that allow you to access various kinds of data in a web application. Those objects are called implicit objects because they are automatically available in the script. These are the common used implicit objects in JSP:
- request object
- response object
- session object
- out object
- pageContext object
- application object
- config object
- page object
- exception object
The request object
Each time a client requests a JSP page, the JSP engine creates a new object that represents the that called request object. The request object is an instance of the class javax.servlet.http.HttpServletRequest. The request object contains all information about the current HTTP request as well as the client. Be noted that request object only available in a scope of the current request. It is re-created each time a new request is made.
By using methods of the request object, you can access various kinds of data e.g., HTTP header, query string, cookies…
The response object
JSP also creates the response object which is an instance of class javax.servlet.http.HttpServletResponse. The response object that represents the response to the client. By using this object, you can add new cookies and change MIME content type of the page. In addition, the response object also contains sufficient information on the HTTP to be able to return the HTTP status code or make the page redirect to another page.
The session object
The session object is used to track information of a particular client between multiple requests. The session object is available in server side so it helps you to preserve the state of the application between multiple requests. You can use the session object to store arbitrary information between client requests. The session object is an instance of the class javax.servlet.http.HttpSession.
The out object
The output stream is exposed to the JSP through the out object. the out object is an instance of the class javax.servlet.jsp.JspWriter. The out object may refer to an output stream or a filtered stream. You can use the out object methods to send the data to the output stream such as using the println() method and JSP takes care the rest.
The pageContext object
The pageContext object represents the entire JSP page. You can use the pageContext object to get attributes of a page. the pageContext object is an instance of the class javax.servlet.jsp.pagecontext.
The application object
The application object is a representation of JSP page through its life cycle. The application object is created when a JSP page is initialized, when the JSP page is removed by jspDestroy() method or when the JSP page is recompiled. As its name implies, the information of the application object can be accessible by any object within the JSP page.
The config object
The config object allows you to access the initialization parameters of the Servlet and JSP engine. The config object is an instance of the class javax.servlet.ServletConfig.
The page object
The page object is an instance of a JSP page. By using the page object, you can call any method of the page’s servlet.
The exception object
The exception object contains the exception which is thrown from the previous JSP page. You can use the exception object to generate friendly error message based on error condition to the end-user.