What is Implicit Objects in jsp

Implicit Objects:-

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.
  1. Jsp Implicit Objects
  2. 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.

Object             Class

  1. application         javax.servlet.ServletContext
  2. config                 javax.servlet.ServletConfig
  3. exception           java.lang.Throwable
  4. out                      javax.servlet.jsp.JspWriter
  5. page                   java.lang.Object
  6. PageContext     javax.servlet.jsp.PageContext
  7. request              javax.servlet.ServletRequest
  8. response           javax.servlet.ServletResponse
  9. session              javax.servlet.http.HttpSession

application :-
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 :-
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 :-
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 :-
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


page :-
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 :-
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.

request :-
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.

Popular posts from this blog

What is NBioBSP Java Library?

Draw arrow line example

Capture image from webcam java code, examples