Jsp Implict Object
-
Upload
sai-kiran-vemula -
Category
Documents
-
view
217 -
download
0
Transcript of Jsp Implict Object
8/8/2019 Jsp Implict Object
http://slidepdf.com/reader/full/jsp-implict-object 1/2
During translation phase, the JSP engine declares and initializing a commonly used
variables in the ser vice method of the generated servlet. They are implicitly made
available to a JSP without need of declaring them. These are called implicit variables or objects.
1. request
2. response3. session
4. config
5. application6. page
7. exception
8. out
9. pageContext
1. request:
this object is of type javax.servlet.http.HttpServletRequest. it refers to the current request
to theJSP. By using this object we captupre the client data
ex: in a scriptlet we write<% String name=request.getParameter(“html textbox name”%>
In the above we get the form data directly into the JSP.
2.response:this object is of type javax.servlet.http.HttpServletResponse. it is used for
sending customize response to client.
3.session: this object is of type javax.servlet.http.HttpSession. this is not available in jsp.In a servlet when we implement session tracking , we call method getSession() on therequest object. In a JSP it is implicitly available. If we want to implement session
tracking in a JSP we use this object.
4.config: this object is of type javax.servlet.ServletConfig. when initialization
parameaters are supplied to the JSP explicitly from the Web.xml, we can retrieve them by
using this object.
<%String paramvalue=config.getInitParameter(“paramname”)%>5.application:
this object is of type javax.servlet.ServletContext. it refers to the environment to which
jsp belongs. Using this we retrieve the application level state.Ex: in a servlet or another jsp has stored some information in ServletContext obj, in our
current jsp we retrieve it as
<%String value=(String)application.getAttribute(“name”)%>
6.page:
8/8/2019 Jsp Implict Object
http://slidepdf.com/reader/full/jsp-implict-object 2/2
this is of type java.lang.Object. it refers to the instance of the generated servlest. This is
used rarely in JSP
7. exception:this is of type java.lang.Throwable. this is not available in all jsps. These pages which
are designated as errorpages, can access this object
ex: <% @page isErrorPatge=”true”%>
8.out: this is of the type javax.servlset.jsp.jspWriter. it refers to the output stream for the page. This is used to send html context from the jsp
9. pageContext: this is of the type javax.servlest. jsp.jspPageContext. it refers to the pageenvironment. It does 3 thing
1. it stores reference to the implicit objects. By supplying this single object to any
java helperclass,k we supply all implict objects. That helper calss can retrieve allthe implict by calling getXXXXX() methods on the PageContext object.
Ex: ServletContext context= pageContext.getServletContext();
ServletConfig config= pageContext.getConfig();
HttpSession session= pageContext.getSession();
2. it provides methods to get and set attributes in different scopes
3. it provides methods to dispatching request to other resources on the web
application.Ex: pageContext.include(String relativeurl);
pageContext.forward(String relativeurl);