Make sure to subscribe to our newsletter and be the first to know the news.
IMPLICIT OBJECTS
- JSP simplifier authoring & provides certain objects implicitly to be accessed within a JSP page without any explicit declaration. - These objects are called as implicit objects . - These objects are not declared explicitly but they are provided by Container during translation phase. There are in all 9 implicit objects
TIP FOR STUDENT:It is always recommended to remember the name of this implicit object & their classes in context to interviews..... There are 9 implicit objects:- 1) request. 2) response 3) out 4) session 5) application
6) config
7) page 8)pageContext 9)exception
1) request:- - request object represents all the information about HttpRequest. - Instance of :javax.servlet.http.HttpServletRequest - Scope:request scope.- Using this object we can access headers cookies ,etc.
2) response:- - response object represents response to the client. - Instance of : javax.servlet.http.HttpServletResponse.
Scope:page scope- response object is used for adding cookies, redirecting the calls,etc
3) out:- - out object represents output stream. - out objects are used for sending arguments to print methods. - Instance of:javax.servlet.jsp.JSPWriter -Scope:page scope
4) session:- - session object is used to track client's information across the session. - Instance of: javax.servlet.http.HttpSession - Scope:session scope.
5) application:- - application object represent the context for the JSP page. - application object is accessible to any object used within JSP page. - Instance of:javax.servlet.ServletConfig - Scope:page scope.
6) config:- - config object provides access to the initialization parameters - Instance of : javax.servlet.ServletConfig - Scope : page scope
7) page:- - page refers to the instance of JSP implementation class, i.e the JSP itself. - accessed using 'this' reference. - Instance of : javax.lang.Object - Scope:page scope.
8) pageContext:- - pageContext encapsulates other implicit objects. - If a class is given pageContext reference it get access to all the objects from all the scope - Instance of : javax.servlet.jsp.PageContext - Scope:page scope.
9) exception:--
Refers to runtime exception that resulted in invoking the errorPage.
- Available only in error page. - errorPage:- a JSP which has is errorPage attribute true in page directive. - Instance of :java.lang.Throwable - Scope:page scope.