SlideShare a Scribd company logo
page Context and Exception
implicit object
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
page Context implicit object
 In JSP, pageContext is an implicit object of type
PageContext class.
 The pageContext object can be used to set,get or
remove attribute from one of the following scopes:
 page
 request
 session
 application
page implicit object:
 In JSP, page is an implicit object of type Object class.
 This object is assigned to the reference of auto
generated servlet class.
 It is written as:
 Object page=this;
 For using this object it must be cast to Servlet type.
Cont..
 For example:
 <% (HttpServlet)page.log("message"); %>
 Since, it is of type Object it is less used because you
can use this object directly in jsp.
 For example:
 <% this.log("message"); %>
Exception implicit object
 In JSP, exception is an implicit object of type
java.lang.Throwable class.
 This object can be used to print the exception. But it
can only be used in error pages.
Example of exception implicit
object:
 error.jsp
 <%@ page isErrorPage="true" %>
 <html>
 <body>
 Sorry following exception occured:<%= exception %>
 </body>
 </html>
index.jsp
 <form action="process.jsp">
 No1:<input type="text" name="n1" /><br/><br/>
 No1:<input type="text" name="n2" /><br/><br/>
 <input type="submit" value="divide"/>
 </form>
process.jsp
 <%@ page errorPage="error.jsp" %>
 <%
 String num1=request.getParameter("n1");
 String num2=request.getParameter("n2");

 int a=Integer.parseInt(num1);
 int b=Integer.parseInt(num2);
 int c=a/b;
 out.print("division of numbers is: "+c);
 %>
error.jsp
 <%@ page isErrorPage="true" %>
 <h3>Sorry an exception occured!</h3>
 Exception is: <%= exception %>
Assignment
 Explain page Context and Exception implicit object
with suitable example.

More Related Content

PPTX
Jsp request implicit object
PPTX
Jsp session implicit object
PPTX
PPTX
Custom filters in mule soft
PPTX
AngularJS best practices
PPTX
Java script functions
PPTX
Endpoint node.js framework presentation
Jsp request implicit object
Jsp session implicit object
Custom filters in mule soft
AngularJS best practices
Java script functions
Endpoint node.js framework presentation

Similar to Page context and exception implicit object (20)

PPTX
Jsp session 3
PPTX
Introduction to JSP.pptx
PPT
3.jsp tutorial
PPTX
Jsp Introduction Tutorial
PPTX
JSP.pptx programming guide for beginners and experts
PPTX
Implicit objects advance Java
PPTX
Jsp config implicit object
PPT
Jsp 02(jsp directives)2003
PDF
J2EE jsp_03
PPTX
Introduction - Java Server Programming (JSP)
PPT
Web&java. jsp
PPT
Web&java. jsp
PDF
JavaServer Pages Pocket Reference 1st Edition Hans Bergsten
PDF
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
DOC
Jsp advance part i
DOC
DOC
PPTX
JSP- JAVA SERVER PAGES
PDF
JavaServer Pages Pocket Reference 1st Edition Hans Bergsten
Jsp session 3
Introduction to JSP.pptx
3.jsp tutorial
Jsp Introduction Tutorial
JSP.pptx programming guide for beginners and experts
Implicit objects advance Java
Jsp config implicit object
Jsp 02(jsp directives)2003
J2EE jsp_03
Introduction - Java Server Programming (JSP)
Web&java. jsp
Web&java. jsp
JavaServer Pages Pocket Reference 1st Edition Hans Bergsten
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Jsp advance part i
JSP- JAVA SERVER PAGES
JavaServer Pages Pocket Reference 1st Edition Hans Bergsten
Ad

More from chauhankapil (20)

PPTX
Gray level transformation
PPTX
Elements of visual perception
PPTX
JSP Client Request
PPTX
Jsp server response
PPTX
Markov decision process
PPTX
RNN basics in deep learning
PPTX
Introduction to generative adversarial networks (GANs)
PPTX
Bayesian probabilistic interference
PPTX
PPTX
Exception handling in java
PPTX
Knowledge acquistion
PPTX
Knowledge based system
PPTX
Introduction of predicate logics
PPTX
Types of inheritance in java
PPTX
Representation of syntax, semantics and Predicate logics
PPTX
Inheritance in java
PPTX
Propositional logic
PPTX
Constructors in java
PPTX
Methods in java
PPT
Circular linked list
Gray level transformation
Elements of visual perception
JSP Client Request
Jsp server response
Markov decision process
RNN basics in deep learning
Introduction to generative adversarial networks (GANs)
Bayesian probabilistic interference
Exception handling in java
Knowledge acquistion
Knowledge based system
Introduction of predicate logics
Types of inheritance in java
Representation of syntax, semantics and Predicate logics
Inheritance in java
Propositional logic
Constructors in java
Methods in java
Circular linked list
Ad

Recently uploaded (20)

PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Digital Logic Computer Design lecture notes
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
DOCX
573137875-Attendance-Management-System-original
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Well-logging-methods_new................
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
composite construction of structures.pdf
R24 SURVEYING LAB MANUAL for civil enggi
OOP with Java - Java Introduction (Basics)
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
UNIT 4 Total Quality Management .pptx
Construction Project Organization Group 2.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Foundation to blockchain - A guide to Blockchain Tech
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Lecture Notes Electrical Wiring System Components
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Digital Logic Computer Design lecture notes
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Operating System & Kernel Study Guide-1 - converted.pdf
573137875-Attendance-Management-System-original
bas. eng. economics group 4 presentation 1.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Well-logging-methods_new................
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
composite construction of structures.pdf

Page context and exception implicit object

  • 1. page Context and Exception implicit object Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2. page Context implicit object  In JSP, pageContext is an implicit object of type PageContext class.  The pageContext object can be used to set,get or remove attribute from one of the following scopes:  page  request  session  application
  • 3. page implicit object:  In JSP, page is an implicit object of type Object class.  This object is assigned to the reference of auto generated servlet class.  It is written as:  Object page=this;  For using this object it must be cast to Servlet type.
  • 4. Cont..  For example:  <% (HttpServlet)page.log("message"); %>  Since, it is of type Object it is less used because you can use this object directly in jsp.  For example:  <% this.log("message"); %>
  • 5. Exception implicit object  In JSP, exception is an implicit object of type java.lang.Throwable class.  This object can be used to print the exception. But it can only be used in error pages.
  • 6. Example of exception implicit object:  error.jsp  <%@ page isErrorPage="true" %>  <html>  <body>  Sorry following exception occured:<%= exception %>  </body>  </html>
  • 7. index.jsp  <form action="process.jsp">  No1:<input type="text" name="n1" /><br/><br/>  No1:<input type="text" name="n2" /><br/><br/>  <input type="submit" value="divide"/>  </form>
  • 8. process.jsp  <%@ page errorPage="error.jsp" %>  <%  String num1=request.getParameter("n1");  String num2=request.getParameter("n2");   int a=Integer.parseInt(num1);  int b=Integer.parseInt(num2);  int c=a/b;  out.print("division of numbers is: "+c);  %>
  • 9. error.jsp  <%@ page isErrorPage="true" %>  <h3>Sorry an exception occured!</h3>  Exception is: <%= exception %>
  • 10. Assignment  Explain page Context and Exception implicit object with suitable example.