SlideShare a Scribd company logo
Implicit Objects
Agenda
โ€ข Understanding built In Objects
โ€ข Request, response
โ€ข Out
โ€ข session
โ€ข exception
โ€ข page and application scope
Implicit Object
โ€ข A JSP page has access to certain implicit objects that are always
available, without being declared first
โ€ข Created by container
โ€ข Corresponds to classes defined in Servlet
Implicit Object
- Provide access to many servlet capabilities within a JSP
- Four scopes
โ€ข Application scope
- Objects owned by the container application
- Any servlet or JSP can manipulate these objects
โ€ข Session scope
- Objects exist for duration of clientโ€™s browsing session
- Objects go out of scope when client terminates session or when
session timeout occurs
โ€ข Request scope
- Objects exist for duration of client request
- Objects go out of scope after response sent to client
โ€ข Page scope
- Objects that exist only in page in which they are defined
- Each page has its own instance of these objects
Implicit Object
Implicit object Description
Application Scope
application This javax.servlet.ServletContext object represents the container in which the JSP
executes.
Page Scope
config This javax.servlet.ServletConfig object represents the JSP configuration options. As
with servlets, configuration options can be specified in a Web application descriptor.
exception This java.lang.Throwable object represents the exception that is passed to the JSP error
page. This object is available only in a JSP error page.
out This javax.servlet.jsp.JspWriter object writes text as part of the response to a request.
This object is used implicitly with JSP expressions and actions that insert string content in a
response.
page This java.lang.Object object represents the this reference for the current JSP instance.
pageContext This javax.servlet.jsp.PageContext object hides the implementation details of the
underlying servlet and JSP container and provides JSP programmers with access to the implicit
objects discussed in this table.
response This object represents the response to the client and is normally an instance of a class that
implements HttpServletResponse (package javax.servlet.http). If a protocol other
than HTTP is used, this object is an instance of a class that implements
javax.servlet.ServletResponse.
Request Scope
request This object represents the client request. The object normally is an instance of a class that
implements HttpServletRequest (package javax.servlet.http). If a protocol other
than HTTP is used, this object is an instance of a subclass of javax.servlet.Servlet-
Request.
Session Scope
session This javax.servlet.http.HttpSession object represents the client session information
if such a session has been created. This object is available only in pages that participate in a
session.
Implicit Object and their classes
โ€ข request (HttpServletRequest)
โ€ข response (HttpServletRepsonse)
โ€ข session (HttpSession)
โ€ข application(ServletContext)
โ€ข out (of type JspWriter)
โ€ข config (ServletConfig)
โ€ข pageContext(this)
Creating an exception with an error page
โ€ข Determine the exception thrown
โ€ข In each of your JSP, include the name of the error page
- <%@ page errorPage="errorpage.jsp" %>
โ€ข Develop an error page, it should include
- <%@ page isErrorPage="true" %>
โ€ข In the error page, use the exception reference to display exception
information
<%= exception.toString() %>
About Exception Object
โ€ข Instance of java.lang.Throwable
โ€ข It is available in those pages where isError page directive is set to
true
โ€ข Important methods
- public String getlocalizedMessage()
- public String getMessage()
- public void printStackTrace()
- public void printStackTrace(PrintStream ps)
- public void printStackTrace(PrintWriter pw)
Session Object
โ€ข This denotes the data associated with a specific session of user.
โ€ข The class or the interface name of the object Session is
http.HttpSession.
โ€ข The previous two objects, request and response, are used to pass
information from web browser to server and from server to web
browser respectively.
โ€ข The Session Object provides the connection or association between
the client and the server.
โ€ข The main use of Session Objects is for maintaining states hen there
are multiple page requests.
Session Object
โ€ข It is an instanceof javax.servlet.http.HttpSession
โ€ข getAttributes returns the bounded object or null
โ€ข getAttributes return Enumeration of String Objects containing names
of all Object bounded to the session
โ€ข getCreationTime returns the time in millseconds when the session
โ€ข isNew() returns true if the server has created a session that hasnโ€™t been
accessed by the client
โ€ข getId() returns String Object containing a unique identifier for his
session
โ€ข Invalidate() invalidates the session and unbinds any object bound to it
Request Object
โ€ข The request object is an instance of a
javax.servlet.http.HttpServletRequest object. Each time a client
requests a page the JSP engine creates a new object to represent
that request.
โ€ข The request object provides methods to get HTTP header
information including form data, cookies, HTTP methods etc.
Request Object methods
โ€ข public Object getAttribute(String name)
โ€ข getAttributeNames() returns an Enumeration containing the attribute names
available to the invoking ServletRequest object:
โ€ข public java.util.Enumeration getAttributeNames()
โ€ข getAuthType() returns the name of the authentication scheme used in the
request or null if no authentication scheme was used. It returns one of the
constants BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, or
DIGEST_AUTH, or it returns null if the request wasn't authenticated:
โ€ข public String getAuthType()
โ€ข getCharacterEncoding() returns a String object containing the character
encoding used in the body of the request or null if there's no encoding:
โ€ข public String getCharacterEncoding()
Request Object methods
โ€ข public Object getAttribute(String name)
โ€ข getAttributeNames() returns an Enumeration containing the attribute names
available to the invoking ServletRequest object:
โ€ข public java.util.Enumeration getAttributeNames()
โ€ข getAuthType() returns the name of the authentication scheme used in the
request or null if no authentication scheme was used. It returns one of the
constants BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, or
DIGEST_AUTH, or it returns null if the request wasn't authenticated:
โ€ข public String getAuthType()
โ€ข getCharacterEncoding() returns a String object containing the character
encoding used in the body of the request or null if there's no encoding:
โ€ข public String getCharacterEncoding()
Response Object
โ€ข The response object is an instance of a
javax.servlet.http.HttpServletResponse object. Just as the server
creates the request object, it also creates an object to represent the
response to the client.
โ€ข The response object also 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.
out Object
โ€ข The out implicit object is an instance of a javax.servlet.jsp.JspWriter
object and is used to send content in a response.
โ€ข The initial JspWriter object is instantiated differently depending on
whether the page is buffered or not. Buffering can be easily turned off
by using the buffered='false' attribute of the page directive.
โ€ข The JspWriter object contains most of the same methods as the
java.io.PrintWriter class. However, JspWriter has some additional
methods designed to deal with buffering. Unlike the PrintWriter object,
JspWriter throws IOExceptions.
application Object
โ€ข The application object is direct wrapper around the ServletContext
object for the generated Servlet and in reality an instance of a
javax.servlet.ServletContext object.
โ€ข This object is a representation of the JSP page through its entire
lifecycle. This object is created when the JSP page is initialized and will
be removed when the JSP page is removed by the jspDestroy() method.
โ€ข By adding an attribute to application, you can ensure that all JSP files
that make up your web application have access to it.
config Object
โ€ข The config object is an instantiation of javax.servlet.ServletConfig and
is a direct wrapper around the ServletConfig object for the generated
servlet.
โ€ข This object allows the JSP programmer access to the Servlet or JSP
engine initialization parameters such as the paths or file locations etc.
pageContext Object
โ€ข The pageContext object is an instance of a javax.servlet.jsp.PageContext object. The
pageContext object is used to represent the entire JSP page.
โ€ข This object is intended as a means to access information about the page while
avoiding most of the implementation details.
โ€ข This object stores references to the request and response objects for each request.
The application, config, session, and out objects are derived by accessing attributes
of this object.
โ€ข The pageContext object also contains information about the directives issued to the
JSP page, including the buffering information, the errorPageURL, and page scope.
โ€ข The PageContext class defines several fields, including PAGE_SCOPE,
REQUEST_SCOPE, SESSION_SCOPE, and APPLICATION_SCOPE, which
identify the four scopes. It also supports more than 40 methods, about half of which
are inherited from the javax.servlet.jsp. JspContext class
Summary
โ€ข Implicit Objects
- page
- request
- session
- application
- response
- out
- cexception
Ad

More Related Content

What's hot (20)

Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Fahad Golra
ย 
.NET Core, ASP.NET Core Course, Session 14
.NET Core, ASP.NET Core Course, Session 14.NET Core, ASP.NET Core Course, Session 14
.NET Core, ASP.NET Core Course, Session 14
Amin Mesbahi
ย 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
Rakesh K. Cherukuri
ย 
Rest
Rest Rest
Rest
Ivano Malavolta
ย 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Training
sourabh aggarwal
ย 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
Richard Paul
ย 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer Reference
Muthuselvam RS
ย 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
SPTechCon
ย 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
kamal kotecha
ย 
JPA Best Practices
JPA Best PracticesJPA Best Practices
JPA Best Practices
Carol McDonald
ย 
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
Amin Mesbahi
ย 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
WO Community
ย 
Hibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic IntroductionHibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic Introduction
Er. Gaurav Kumar
ย 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
ย 
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)
Sameer Rathoud
ย 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
Subin Sugunan
ย 
Deployment
DeploymentDeployment
Deployment
Roy Antony Arnold G
ย 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
Daniel Ballinger
ย 
Wcf data services
Wcf data servicesWcf data services
Wcf data services
Eyal Vardi
ย 
Object identification and its management
Object identification and its managementObject identification and its management
Object identification and its management
Vinay Kumar Pulabaigari
ย 
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Fahad Golra
ย 
.NET Core, ASP.NET Core Course, Session 14
.NET Core, ASP.NET Core Course, Session 14.NET Core, ASP.NET Core Course, Session 14
.NET Core, ASP.NET Core Course, Session 14
Amin Mesbahi
ย 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
Rakesh K. Cherukuri
ย 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Training
sourabh aggarwal
ย 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
Richard Paul
ย 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer Reference
Muthuselvam RS
ย 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
SPTechCon
ย 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
kamal kotecha
ย 
JPA Best Practices
JPA Best PracticesJPA Best Practices
JPA Best Practices
Carol McDonald
ย 
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
Amin Mesbahi
ย 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
WO Community
ย 
Hibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic IntroductionHibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic Introduction
Er. Gaurav Kumar
ย 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
ย 
Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)Proxy design pattern (Class Ambassador)
Proxy design pattern (Class Ambassador)
Sameer Rathoud
ย 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
Subin Sugunan
ย 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
Daniel Ballinger
ย 
Wcf data services
Wcf data servicesWcf data services
Wcf data services
Eyal Vardi
ย 
Object identification and its management
Object identification and its managementObject identification and its management
Object identification and its management
Vinay Kumar Pulabaigari
ย 

Similar to Advance java session 11 (20)

Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
PawanMM
ย 
Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6
PawanMM
ย 
J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environment
joearunraja2
ย 
Advance java session 18
Advance java session 18Advance java session 18
Advance java session 18
Smita B Kumar
ย 
Servlet
ServletServlet
Servlet
baabtra.com - No. 1 supplier of quality freshers
ย 
Servlets
ServletsServlets
Servlets
Sasidhar Kothuru
ย 
Implicit Objects &Handling.pptx
Implicit Objects &Handling.pptxImplicit Objects &Handling.pptx
Implicit Objects &Handling.pptx
KSuvetha1
ย 
Core web application development
Core web application developmentCore web application development
Core web application development
Bahaa Farouk
ย 
Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5
PawanMM
ย 
Jsp session 3
Jsp   session 3Jsp   session 3
Jsp session 3
Anuj Singh Rajput
ย 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
ย 
WT Unit-Vuufvmjn dissimilating Dunkirk k
WT Unit-Vuufvmjn dissimilating Dunkirk kWT Unit-Vuufvmjn dissimilating Dunkirk k
WT Unit-Vuufvmjn dissimilating Dunkirk k
asta9578
ย 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
ย 
SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4
Ben Abdallah Helmi
ย 
Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
vamsi krishna
ย 
Servlet11
Servlet11Servlet11
Servlet11
patinijava
ย 
Implicit objects advance Java
Implicit objects advance JavaImplicit objects advance Java
Implicit objects advance Java
Darshit Metaliya
ย 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...
MathivananP4
ย 
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
tahirnaquash2
ย 
Chap4 4 1
Chap4 4 1Chap4 4 1
Chap4 4 1
Hemo Chella
ย 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
PawanMM
ย 
Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6
PawanMM
ย 
J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environment
joearunraja2
ย 
Advance java session 18
Advance java session 18Advance java session 18
Advance java session 18
Smita B Kumar
ย 
Implicit Objects &Handling.pptx
Implicit Objects &Handling.pptxImplicit Objects &Handling.pptx
Implicit Objects &Handling.pptx
KSuvetha1
ย 
Core web application development
Core web application developmentCore web application development
Core web application development
Bahaa Farouk
ย 
Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5Session 29 - Servlets - Part 5
Session 29 - Servlets - Part 5
PawanMM
ย 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
ย 
WT Unit-Vuufvmjn dissimilating Dunkirk k
WT Unit-Vuufvmjn dissimilating Dunkirk kWT Unit-Vuufvmjn dissimilating Dunkirk k
WT Unit-Vuufvmjn dissimilating Dunkirk k
asta9578
ย 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
ย 
SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4
Ben Abdallah Helmi
ย 
Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
vamsi krishna
ย 
Servlet11
Servlet11Servlet11
Servlet11
patinijava
ย 
Implicit objects advance Java
Implicit objects advance JavaImplicit objects advance Java
Implicit objects advance Java
Darshit Metaliya
ย 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...
MathivananP4
ย 
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.pptModule 4.ppt
Module 4.pptModule 4.pptModule 4.pptModule 4.ppt
tahirnaquash2
ย 
Chap4 4 1
Chap4 4 1Chap4 4 1
Chap4 4 1
Hemo Chella
ย 
Ad

More from Smita B Kumar (19)

Advance java session 20
Advance java session 20Advance java session 20
Advance java session 20
Smita B Kumar
ย 
Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19
Smita B Kumar
ย 
Advance java session 17
Advance java session 17Advance java session 17
Advance java session 17
Smita B Kumar
ย 
Advance java session 16
Advance java session 16Advance java session 16
Advance java session 16
Smita B Kumar
ย 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
Smita B Kumar
ย 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
Smita B Kumar
ย 
Advance java session 13
Advance java session 13Advance java session 13
Advance java session 13
Smita B Kumar
ย 
Advance java session 12
Advance java session 12Advance java session 12
Advance java session 12
Smita B Kumar
ย 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
Smita B Kumar
ย 
Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
Smita B Kumar
ย 
Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8
Smita B Kumar
ย 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
Smita B Kumar
ย 
Advance java session 6
Advance java session 6Advance java session 6
Advance java session 6
Smita B Kumar
ย 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
Smita B Kumar
ย 
Advance java session 4
Advance java session 4Advance java session 4
Advance java session 4
Smita B Kumar
ย 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3
Smita B Kumar
ย 
Advance java session 2
Advance java session 2Advance java session 2
Advance java session 2
Smita B Kumar
ย 
JEE session 1
JEE session 1JEE session 1
JEE session 1
Smita B Kumar
ย 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2
Smita B Kumar
ย 
Advance java session 20
Advance java session 20Advance java session 20
Advance java session 20
Smita B Kumar
ย 
Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19
Smita B Kumar
ย 
Advance java session 17
Advance java session 17Advance java session 17
Advance java session 17
Smita B Kumar
ย 
Advance java session 16
Advance java session 16Advance java session 16
Advance java session 16
Smita B Kumar
ย 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
Smita B Kumar
ย 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
Smita B Kumar
ย 
Advance java session 13
Advance java session 13Advance java session 13
Advance java session 13
Smita B Kumar
ย 
Advance java session 12
Advance java session 12Advance java session 12
Advance java session 12
Smita B Kumar
ย 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
Smita B Kumar
ย 
Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
Smita B Kumar
ย 
Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8
Smita B Kumar
ย 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
Smita B Kumar
ย 
Advance java session 6
Advance java session 6Advance java session 6
Advance java session 6
Smita B Kumar
ย 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
Smita B Kumar
ย 
Advance java session 4
Advance java session 4Advance java session 4
Advance java session 4
Smita B Kumar
ย 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3
Smita B Kumar
ย 
Advance java session 2
Advance java session 2Advance java session 2
Advance java session 2
Smita B Kumar
ย 
JEE session 1
JEE session 1JEE session 1
JEE session 1
Smita B Kumar
ย 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2
Smita B Kumar
ย 
Ad

Recently uploaded (20)

Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
ย 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
ย 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
ย 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
HCL Nomad Web โ€“ Best Practices and Managing Multiuser Environments
HCL Nomad Web โ€“ Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web โ€“ Best Practices and Managing Multiuser Environments
HCL Nomad Web โ€“ Best Practices and Managing Multiuser Environments
panagenda
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
ย 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
ย 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
ย 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
HCL Nomad Web โ€“ Best Practices and Managing Multiuser Environments
HCL Nomad Web โ€“ Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web โ€“ Best Practices and Managing Multiuser Environments
HCL Nomad Web โ€“ Best Practices and Managing Multiuser Environments
panagenda
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
ย 

Advance java session 11

  • 2. Agenda โ€ข Understanding built In Objects โ€ข Request, response โ€ข Out โ€ข session โ€ข exception โ€ข page and application scope
  • 3. Implicit Object โ€ข A JSP page has access to certain implicit objects that are always available, without being declared first โ€ข Created by container โ€ข Corresponds to classes defined in Servlet
  • 4. Implicit Object - Provide access to many servlet capabilities within a JSP - Four scopes โ€ข Application scope - Objects owned by the container application - Any servlet or JSP can manipulate these objects โ€ข Session scope - Objects exist for duration of clientโ€™s browsing session - Objects go out of scope when client terminates session or when session timeout occurs โ€ข Request scope - Objects exist for duration of client request - Objects go out of scope after response sent to client โ€ข Page scope - Objects that exist only in page in which they are defined - Each page has its own instance of these objects
  • 5. Implicit Object Implicit object Description Application Scope application This javax.servlet.ServletContext object represents the container in which the JSP executes. Page Scope config This javax.servlet.ServletConfig object represents the JSP configuration options. As with servlets, configuration options can be specified in a Web application descriptor. exception This java.lang.Throwable object represents the exception that is passed to the JSP error page. This object is available only in a JSP error page. out This javax.servlet.jsp.JspWriter object writes text as part of the response to a request. This object is used implicitly with JSP expressions and actions that insert string content in a response. page This java.lang.Object object represents the this reference for the current JSP instance. pageContext This javax.servlet.jsp.PageContext object hides the implementation details of the underlying servlet and JSP container and provides JSP programmers with access to the implicit objects discussed in this table. response This object represents the response to the client and is normally an instance of a class that implements HttpServletResponse (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a class that implements javax.servlet.ServletResponse. Request Scope request This object represents the client request. The object normally is an instance of a class that implements HttpServletRequest (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a subclass of javax.servlet.Servlet- Request. Session Scope session This javax.servlet.http.HttpSession object represents the client session information if such a session has been created. This object is available only in pages that participate in a session.
  • 6. Implicit Object and their classes โ€ข request (HttpServletRequest) โ€ข response (HttpServletRepsonse) โ€ข session (HttpSession) โ€ข application(ServletContext) โ€ข out (of type JspWriter) โ€ข config (ServletConfig) โ€ข pageContext(this)
  • 7. Creating an exception with an error page โ€ข Determine the exception thrown โ€ข In each of your JSP, include the name of the error page - <%@ page errorPage="errorpage.jsp" %> โ€ข Develop an error page, it should include - <%@ page isErrorPage="true" %> โ€ข In the error page, use the exception reference to display exception information <%= exception.toString() %>
  • 8. About Exception Object โ€ข Instance of java.lang.Throwable โ€ข It is available in those pages where isError page directive is set to true โ€ข Important methods - public String getlocalizedMessage() - public String getMessage() - public void printStackTrace() - public void printStackTrace(PrintStream ps) - public void printStackTrace(PrintWriter pw)
  • 9. Session Object โ€ข This denotes the data associated with a specific session of user. โ€ข The class or the interface name of the object Session is http.HttpSession. โ€ข The previous two objects, request and response, are used to pass information from web browser to server and from server to web browser respectively. โ€ข The Session Object provides the connection or association between the client and the server. โ€ข The main use of Session Objects is for maintaining states hen there are multiple page requests.
  • 10. Session Object โ€ข It is an instanceof javax.servlet.http.HttpSession โ€ข getAttributes returns the bounded object or null โ€ข getAttributes return Enumeration of String Objects containing names of all Object bounded to the session โ€ข getCreationTime returns the time in millseconds when the session โ€ข isNew() returns true if the server has created a session that hasnโ€™t been accessed by the client โ€ข getId() returns String Object containing a unique identifier for his session โ€ข Invalidate() invalidates the session and unbinds any object bound to it
  • 11. Request Object โ€ข The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a client requests a page the JSP engine creates a new object to represent that request. โ€ข The request object provides methods to get HTTP header information including form data, cookies, HTTP methods etc.
  • 12. Request Object methods โ€ข public Object getAttribute(String name) โ€ข getAttributeNames() returns an Enumeration containing the attribute names available to the invoking ServletRequest object: โ€ข public java.util.Enumeration getAttributeNames() โ€ข getAuthType() returns the name of the authentication scheme used in the request or null if no authentication scheme was used. It returns one of the constants BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, or DIGEST_AUTH, or it returns null if the request wasn't authenticated: โ€ข public String getAuthType() โ€ข getCharacterEncoding() returns a String object containing the character encoding used in the body of the request or null if there's no encoding: โ€ข public String getCharacterEncoding()
  • 13. Request Object methods โ€ข public Object getAttribute(String name) โ€ข getAttributeNames() returns an Enumeration containing the attribute names available to the invoking ServletRequest object: โ€ข public java.util.Enumeration getAttributeNames() โ€ข getAuthType() returns the name of the authentication scheme used in the request or null if no authentication scheme was used. It returns one of the constants BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, or DIGEST_AUTH, or it returns null if the request wasn't authenticated: โ€ข public String getAuthType() โ€ข getCharacterEncoding() returns a String object containing the character encoding used in the body of the request or null if there's no encoding: โ€ข public String getCharacterEncoding()
  • 14. Response Object โ€ข The response object is an instance of a javax.servlet.http.HttpServletResponse object. Just as the server creates the request object, it also creates an object to represent the response to the client. โ€ข The response object also 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.
  • 15. out Object โ€ข The out implicit object is an instance of a javax.servlet.jsp.JspWriter object and is used to send content in a response. โ€ข The initial JspWriter object is instantiated differently depending on whether the page is buffered or not. Buffering can be easily turned off by using the buffered='false' attribute of the page directive. โ€ข The JspWriter object contains most of the same methods as the java.io.PrintWriter class. However, JspWriter has some additional methods designed to deal with buffering. Unlike the PrintWriter object, JspWriter throws IOExceptions.
  • 16. application Object โ€ข The application object is direct wrapper around the ServletContext object for the generated Servlet and in reality an instance of a javax.servlet.ServletContext object. โ€ข This object is a representation of the JSP page through its entire lifecycle. This object is created when the JSP page is initialized and will be removed when the JSP page is removed by the jspDestroy() method. โ€ข By adding an attribute to application, you can ensure that all JSP files that make up your web application have access to it.
  • 17. config Object โ€ข The config object is an instantiation of javax.servlet.ServletConfig and is a direct wrapper around the ServletConfig object for the generated servlet. โ€ข This object allows the JSP programmer access to the Servlet or JSP engine initialization parameters such as the paths or file locations etc.
  • 18. pageContext Object โ€ข The pageContext object is an instance of a javax.servlet.jsp.PageContext object. The pageContext object is used to represent the entire JSP page. โ€ข This object is intended as a means to access information about the page while avoiding most of the implementation details. โ€ข This object stores references to the request and response objects for each request. The application, config, session, and out objects are derived by accessing attributes of this object. โ€ข The pageContext object also contains information about the directives issued to the JSP page, including the buffering information, the errorPageURL, and page scope. โ€ข The PageContext class defines several fields, including PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, and APPLICATION_SCOPE, which identify the four scopes. It also supports more than 40 methods, about half of which are inherited from the javax.servlet.jsp. JspContext class
  • 19. Summary โ€ข Implicit Objects - page - request - session - application - response - out - cexception