Thursday, 23 February 2017

JSP Implicit Objects

JSP Implicit Objects

JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer can call them directly without declaring them explicitly. These objects are created by JSP Engine during translation phase (while translating JSP to Servlet). They are being created inside service method so the developer can directly use them within Scriptlet without initializing and declaring them.

There are total 8+1 implicit objects available in JSP.

The request Object
The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a client requests a page the JSP engine creates a new object to represent that request.
The request object provides methods to get HTTP header information including form data, cookies, HTTP methods etc.
The response Object:
The response object is an instance of a javax.servlet.http.HttpServletResponse object. The server creates the response object to represent the response to the client.
The out Object:
The out object is an instance of a javax.servlet.jsp.JspWriter object and is used to send content in a response.
The JspWriter object contains most of the methods as the class.
The session Object:
The session object is an instance of javax.servlet.http.HttpSession and behaves exactly the same way that session objects behave under Java Servlets.
The session object is used to track client session between client requests.
The application Object:
The application object is an instance of a javax.servlet.ServletContext.
Application object is a representation of the JSP page through its entire lifecycle. This object is created when the JSP page is initialized and will be removed when the JSP page is removed by the jspDestroy() method.
The config Object:
The config object is an instantiation of javax.servlet.ServletConfig.
The config object allows the JSP programmer access to the Servlet or JSP engine initialization parameters such as the paths or file locations etc.
The pageContext Object:
The pageContext object is an instance of  javax.servlet.jsp.PageContext. The pageContext object is used to represent the entire JSP page.
This object stores references to the request and response objects for each request. The application, config, session, and out objects are derived by accessing attributes of pageContext object.
The page Object:
Page object is a reference to the current Servlet instance (Converted Servlet, generated during translation phase from a JSP page). We can simply use this in place of it.
The exception Object
Exception object is used in exception handling for displaying the error messages. This object is only available to the JSP pages, which has isErrorPage set to true.

JSP Implicit Objects
JSP Implicit Objects

1 comment:

  1. perfect explanation about java programming .its very useful.thanks for your valuable training in chennai | java training in velachery


Related Posts Plugin for WordPress, Blogger...