implicit objects advance java
TRANSCRIPT
![Page 1: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/1.jpg)
Implicit ObjectsAdvance Java
(2160707)
Prepared By::Metaliya Darshit (130110107020)
![Page 2: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/2.jpg)
INTRODUCTIONJSP Implicit Objects are the Java objects that the JSP
Container makes available to developers in each page and developer can call them directly without being explicitly declared.
JSP Implicit Objects are also called pre-defined variables.
![Page 3: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/3.jpg)
Object Description
Request This is the HttpServletRequest object associated with the request.
response This is the HttpServletResponse object associated with the response to the client.
out This is the PrintWriter object used to send output to the client.
session This is the HttpSession object associated with the request.
application This is the ServletContext object associated with application context.
config This is the ServletConfig object associated with the page.
pageContext This encapsulates use of server-specific features like higher performance JspWriters.
page This is simply a synonym for this, and is used to call the methods defined by the translated servlet class.
Exception The Exception object allows the exception data to be accessed by designated JSP.
![Page 4: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/4.jpg)
REQUEST OBJECTImplicit object of type HttpServletRequest i.e. created for
each jsp request by the web container.
Use:To get request information such as parameter, header information, remote address, server name, server port, content type, character encoding To set, get and remove attributes from the jsp request scope.
![Page 5: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/5.jpg)
REQUEST OBJECT Index.html <form action="welcome.jsp"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form>
Newjsp.jsp <% String name=request.getParameter("uname"); out.print("welcome "+name); %>
![Page 6: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/6.jpg)
RESPONSE OBJECTImplicit object of type HttpServletResponse. The instance of
HttpServletResponse is created by the web container for each jsp request.
Defines the interfaces that deal with creating new HTTP headers. Through this object the JSP programmer can add new cookies or date stamps, HTTP status codes etc.
Use:To add or manipulate response such as redirect response to another resource, send error etc.
Newjsp.jsp<% response.sendRedirect("http://www.google.com"); %>
![Page 7: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/7.jpg)
OUT OBJECTInstance of a javax.servlet.jsp.JspWriter object and is used
to send content in a response.
Use:For writing any data to the bufferdisplaying dynamic dataThe java way to display text on the webpage
Newjsp.jsp
<% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>
![Page 8: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/8.jpg)
SESSION OBJECTimplicit object of type HttpSession.
Use:to set, get or remove attribute or to get session information.to track client session between client requests
![Page 9: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/9.jpg)
SESSION OBJECTIndex.html<form action="welcome.jsp"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form>
Newjsp.jsp <% String name=request.getParameter("uname"); out.print("Welcome "+name); session.setAttribute("user",name); %><a href="second.jsp">second jsp page</a>
![Page 10: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/10.jpg)
SESSION OBJECTsecond.jsp<% String name=(String)session.getAttribute("user"); out.print("Hello "+name); %>
![Page 11: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/11.jpg)
APPLICATION OBJECTImplicit object of type ServletContext.
Instance of ServletContext is created only once by the web container when application or project is deployed on the server.
UseTo get initialization parameter from configuaration file (web.xml). To get, set or remove attribute from the application scope.
![Page 12: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/12.jpg)
APPLICATION OBJECTNewjsp.jsp <% out.print("Welcome "+request.getParameter("uname")); String driver=application.getInitParameter("dname"); out.print("driver name is="+driver); %>
![Page 13: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/13.jpg)
CONFIG OBJECTImplicit object of type ServletConfig.
Use:To get initialization parameter for a particular JSP pageAllows the JSP programmer access to the Servlet or JSP engine initialization parameters such as the paths or file locations etc.
![Page 14: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/14.jpg)
CONFIG OBJECT
![Page 15: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/15.jpg)
PAGECONTEXT OBJECTImplicit object of type PageContext class
Intended as a means to access information about the page while avoiding most of the implementation details.
Use: To set, get or remove attribute from one of the following scopes:
pagerequestsessionApplication
In JSP, page scope is the default scope.
![Page 16: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/16.jpg)
PAGECONTEXT OBJECTNewjsp.jsp <% String name=request.getParameter("uname"); out.print("Welcome "+name); pageContext.setAttribute("user",name,PageContext.SESSION_SCOPE); %>
<a href="second.jsp">second jsp page</a>
![Page 17: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/17.jpg)
PAGECONTEXT OBJECTsecond.jsp<% String name=(String)pageContext.getAttribute("user",PageContext.SESSION_SCOPE);
out.print("Hello "+name); %>
![Page 18: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/18.jpg)
PAGE OBJECTAn actual reference to the instance of the page.
It can be thought of as an object that represents the entire JSP page.
implicit object of type java.lang.Throwable class.
The exception object is a wrapper containing the exception thrown from the previous page. It is typically used to generate an appropriate response to the error condition.
![Page 19: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/19.jpg)
EXCEPTION OBJECT implicit object of type java.lang.Throwable class.
A wrapper containing the exception thrown from the previous page.
Use:To generate an appropriate response to the error condition.
![Page 20: Implicit objects advance Java](https://reader035.vdocuments.us/reader035/viewer/2022070516/5871f0b71a28ab5c348b5791/html5/thumbnails/20.jpg)
THANK YOU