In this article, I will try to describe about the objects on the jsp page. There are two type of objects can be on a jsp page.
- Jsp Implicit Objects
- Jsp Explicit Objects
What is Implicit Objects in jsp
Objects which are directly available on the Jsp page are called Implicit object. Actually these objects are Java objects and Jsp container provide these objects on the Jsp page. These objects automatically instantiate on the Jsp page.
Jsp has nine type of Implicit Objects. We are describing these implicit objects below.
- 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 is the object of javax.servlet.ServletContext. It mean scope of this objects are available for all Jsp pages and also on all servlets. application object has only one setter method named
public void setAttribute(java.lang.String name, java.lang.Object object)
So you can set any objects with any name. and this object will be available at any jsp and servlet.
There are many methods that gives the information about container. You can get the init parameter also.
config is the object of javax.servlet.ServletConfig. It gives the information about the jsp container. It has page scope.
It has four methods.
public java.lang.String getServletName()
public ServletContext getServletContext()
public java.lang.String getInitParameter(java.lang.String name)
public java.util.Enumeration getInitParameterNames()
exception is the object of java.lang.Throwable class. exception object is used for handle the exception on the jsp page. It also has page scope. This is specially used in the error page. If you will set the value of isErrorPage as true it means this page will work for display the error.
out is the object of javax.servlet.jsp.JspWriter and it has page scope. It is used to print any value or object on the jsp page.
It has many method like
The Page object denotes the JSP page, used for calling any instance of a Page's servlet. The class or the interface name of the Page object is jsp.HttpJspPage. The Page object is written: Java.lang.Object
PageContext has a page scope. Pagecontext is the 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.
The class or the interface name of the object request is http.httpservletrequest. The object request is of type Javax.servlet.http.httpservletrequest. This denotes the data included with the HTTP Request. The client first makes a request that is then passed to the server. The requested object is used to take the value from client’s web browser and pass it to the server. This is performed using HTTP request like headers, cookies and arguments.