SlideShare a Scribd company logo
1 of 22
Chapter 3



Error Handling



                 http://www.java2all.com
Introduction



               http://www.java2all.com
We already know about error and exception.

   In JSP there are 2 types of exception
1.      Translation time errors
2.      Run Time Exception
       Translation error occurs during page
   compilation, this results in an Internal Server Error
   (500).
       An exception on other hand occurs when page is
   compiled and servlet is running.
       Exception can be handled in JSP in three ways:

                                             http://www.java2all.com
a.) Java Exception Handling mechanism

b.) Dealing with exception with page directive

c.) Dealing with exception in Deployment
    Descriptor.




                                     http://www.java2all.com
By Mechanism




               http://www.java2all.com
Java Exception handling mechanism

InputData.html :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>InputData.html</title>
 </head>
 <body>
  <form action="../JSPFILE/Calculator.jsp">
  <input type="text" name="n1"> <br>
  <input type="text" name="n2"> <br>
  <input type="submit" value="ADD">
  </form>
 </body>
</html>




                                                                  http://www.java2all.com
Calculator.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
 <head>
 <title> Calculator.jsp </title>
 </head>
 <body>
 <% try
   {
     int i1 = Integer.parseInt(request.getParameter("n1"));
     int i2 = Integer.parseInt(request.getParameter("n2"));
     int add = i1 + i2;
     out.print("Addition = "+add);
   }
   catch(NumberFormatException ne)
   {
     out.print("Esception : "+ne);
   }
 %>

 </body>
</html>


                                                                            http://www.java2all.com
URL :
http://localhost:8080/JAVA_PROJECT/HTMLFILE/Input
Data.html




                                        http://www.java2all.com
                                        http://www.java2all.com
Input the integer value in text fields and click
ADD button.

     The browser display the below message,
     Addition = 11

     Now, input the float value in any of the text field
and click ADD button so the browser display the
message,

     Exception :
     java.lang.NumberFormatException: For
input string: "6.3"
                                              http://www.java2all.com
http://www.java2all.com
 http://www.java2all.com
By Page Directive




                    http://www.java2all.com
Dealing exception with page directive :

      The two attributes of page directive
errorPage and isErrorPage are used to deal with
exception.
InputData.html :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>InputData.html</title>
 </head>
 <body>
  <form action="../JSPFILE/Calculator.jsp">
  <input type="text" name="n1"> <br>
  <input type="text" name="n2"> <br>
  <input type="submit" value="ADD">
  </form>
 </body>
</html>
                                                                  http://www.java2all.com
Calculator.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"
errorPage="Error.jsp"%>

<html>
 <head>
 <title> Calculator.jsp </title>
 </head>

 <body>
 <%
    int i1 = Integer.parseInt(request.getParameter("n1"));
    int i2 = Integer.parseInt(request.getParameter("n2"));
    int add = i1 + i2;
    out.print("Addition = "+add);

 %>

 </body>
</html>




                                                                          http://www.java2all.com
Error.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"
isErrorPage="true"%>
<html>
  <head>
  <title>Error.jsp</title>
  </head>
  <body>
  Your page generate an Exception. <br>
  <%= exception.getMessage() %>
  </body>
</html>




                                                                          http://www.java2all.com
Input the integer value in textfields and click
ADD button.

     The browser display the below message,
     Addition = 11

      Now, input the float value in any of the
textfield and click ADD button so the browser
display the message,

     Your page generate an Exception.
     For input string: "6.3"
                                            http://www.java2all.com
In Deployment Descriptor




                      http://www.java2all.com
InputData.html :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>InputData.html</title>
 </head>
 <body>
  <form action="../JSPFILE/Calculator.jsp">
  <input type="text" name="n1"> <br>
  <input type="text" name="n2"> <br>
  <input type="submit" value="ADD">
  </form>
 </body>
</html>




                                                                  http://www.java2all.com
Calculator.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
 <head>
 <title> Calculator.jsp </title>
 </head>

 <body>
 <%
    int i1 = Integer.parseInt(request.getParameter("n1"));
    int i2 = Integer.parseInt(request.getParameter("n2"));
    int add = i1 + i2;
    out.print("Addition = "+add);

 %>

 </body>
</html>




                                                                            http://www.java2all.com
Error.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"
isErrorPage="true"%>
<html>
  <head>
  <title>Error.jsp</title>
  </head>
  <body>
  Your page generate an Exception. <br>
  <%= exception.getMessage() %>
  </body>
</html>




                                                                          http://www.java2all.com
Web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>

 <error-page>
  <exception-
type>java.lang.NumberFormatException</exce
ption-type>
  <location>/Error.jsp</location>
 </error-page>
</web-app>
                                                          http://www.java2all.com
NOTE : web.xml (deployment descriptor) file is
available in WEB-INF folder at WebRoot.

   Input the integer value in textfields and click
ADD button.

     The browser display the below message,
     Addition = 11

      Now, input the float value in any of the
textfield and click ADD button so the browser
display the message,
                                            http://www.java2all.com
Your page generates an Exception.
     For input string: "6.3“

     This deployment descriptor entry means that
whenever a web component throws a
NumberFormatException from any web page in
the whole application(web project),

     the web container call the Error.jsp file,
which simply reports the error message in web
browser.

                                             http://www.java2all.com

More Related Content

What's hot

Javascript operators
Javascript operatorsJavascript operators
Javascript operators
Mohit Rana
 

What's hot (20)

Java interface
Java interfaceJava interface
Java interface
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for Beginners
 
Functions in javascript
Functions in javascriptFunctions in javascript
Functions in javascript
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Delegates and events in C#
Delegates and events in C#Delegates and events in C#
Delegates and events in C#
 
Javascript operators
Javascript operatorsJavascript operators
Javascript operators
 
Java script ppt
Java script pptJava script ppt
Java script ppt
 
JavaScript Looping Statements
JavaScript Looping StatementsJavaScript Looping Statements
JavaScript Looping Statements
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Java applets
Java appletsJava applets
Java applets
 
Java script
Java scriptJava script
Java script
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Applet programming
Applet programming Applet programming
Applet programming
 

Similar to JSP Error handling

การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ลการเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
Bongza Naruk
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
Adil Jafri
 

Similar to JSP Error handling (20)

Jsp element
Jsp elementJsp element
Jsp element
 
Understanding JSP -Servlets
Understanding JSP -ServletsUnderstanding JSP -Servlets
Understanding JSP -Servlets
 
Oracle Endeca Developer's Guide
Oracle Endeca Developer's GuideOracle Endeca Developer's Guide
Oracle Endeca Developer's Guide
 
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ลการเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtp
 
Jsp intro
Jsp introJsp intro
Jsp intro
 
Advanced java practical semester 6_computer science
Advanced java practical semester 6_computer scienceAdvanced java practical semester 6_computer science
Advanced java practical semester 6_computer science
 
Rest hello world_tutorial
Rest hello world_tutorialRest hello world_tutorial
Rest hello world_tutorial
 
Jsp1
Jsp1Jsp1
Jsp1
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 MinutesBuild Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
Test2
Test2Test2
Test2
 
Test2
Test2Test2
Test2
 
Lecture2
Lecture2Lecture2
Lecture2
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and Controllers
 
Ajax3
Ajax3Ajax3
Ajax3
 
Java serverpages
Java serverpagesJava serverpages
Java serverpages
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
 

More from kamal kotecha

Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
kamal kotecha
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
kamal kotecha
 

More from kamal kotecha (20)

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
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
 
Java rmi
Java rmiJava rmi
Java rmi
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySql
 
Jdbc api
Jdbc apiJdbc api
Jdbc api
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of java
 
Interface
InterfaceInterface
Interface
 
Inheritance chepter 7
Inheritance chepter 7Inheritance chepter 7
Inheritance chepter 7
 
Class method
Class methodClass method
Class method
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Control statements
Control statementsControl statements
Control statements
 
Jsp myeclipse
Jsp myeclipseJsp myeclipse
Jsp myeclipse
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 

Recently uploaded

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

JSP Error handling

  • 1. Chapter 3 Error Handling http://www.java2all.com
  • 2. Introduction http://www.java2all.com
  • 3. We already know about error and exception. In JSP there are 2 types of exception 1. Translation time errors 2. Run Time Exception Translation error occurs during page compilation, this results in an Internal Server Error (500). An exception on other hand occurs when page is compiled and servlet is running. Exception can be handled in JSP in three ways: http://www.java2all.com
  • 4. a.) Java Exception Handling mechanism b.) Dealing with exception with page directive c.) Dealing with exception in Deployment Descriptor. http://www.java2all.com
  • 5. By Mechanism http://www.java2all.com
  • 6. Java Exception handling mechanism InputData.html : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>InputData.html</title> </head> <body> <form action="../JSPFILE/Calculator.jsp"> <input type="text" name="n1"> <br> <input type="text" name="n2"> <br> <input type="submit" value="ADD"> </form> </body> </html> http://www.java2all.com
  • 7. Calculator.jsp : <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <html> <head> <title> Calculator.jsp </title> </head> <body> <% try { int i1 = Integer.parseInt(request.getParameter("n1")); int i2 = Integer.parseInt(request.getParameter("n2")); int add = i1 + i2; out.print("Addition = "+add); } catch(NumberFormatException ne) { out.print("Esception : "+ne); } %> </body> </html> http://www.java2all.com
  • 8. URL : http://localhost:8080/JAVA_PROJECT/HTMLFILE/Input Data.html http://www.java2all.com http://www.java2all.com
  • 9. Input the integer value in text fields and click ADD button. The browser display the below message, Addition = 11 Now, input the float value in any of the text field and click ADD button so the browser display the message, Exception : java.lang.NumberFormatException: For input string: "6.3" http://www.java2all.com
  • 11. By Page Directive http://www.java2all.com
  • 12. Dealing exception with page directive : The two attributes of page directive errorPage and isErrorPage are used to deal with exception. InputData.html : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>InputData.html</title> </head> <body> <form action="../JSPFILE/Calculator.jsp"> <input type="text" name="n1"> <br> <input type="text" name="n2"> <br> <input type="submit" value="ADD"> </form> </body> </html> http://www.java2all.com
  • 13. Calculator.jsp : <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1" errorPage="Error.jsp"%> <html> <head> <title> Calculator.jsp </title> </head> <body> <% int i1 = Integer.parseInt(request.getParameter("n1")); int i2 = Integer.parseInt(request.getParameter("n2")); int add = i1 + i2; out.print("Addition = "+add); %> </body> </html> http://www.java2all.com
  • 14. Error.jsp : <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1" isErrorPage="true"%> <html> <head> <title>Error.jsp</title> </head> <body> Your page generate an Exception. <br> <%= exception.getMessage() %> </body> </html> http://www.java2all.com
  • 15. Input the integer value in textfields and click ADD button. The browser display the below message, Addition = 11 Now, input the float value in any of the textfield and click ADD button so the browser display the message, Your page generate an Exception. For input string: "6.3" http://www.java2all.com
  • 16. In Deployment Descriptor http://www.java2all.com
  • 17. InputData.html : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>InputData.html</title> </head> <body> <form action="../JSPFILE/Calculator.jsp"> <input type="text" name="n1"> <br> <input type="text" name="n2"> <br> <input type="submit" value="ADD"> </form> </body> </html> http://www.java2all.com
  • 18. Calculator.jsp : <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <html> <head> <title> Calculator.jsp </title> </head> <body> <% int i1 = Integer.parseInt(request.getParameter("n1")); int i2 = Integer.parseInt(request.getParameter("n2")); int add = i1 + i2; out.print("Addition = "+add); %> </body> </html> http://www.java2all.com
  • 19. Error.jsp : <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1" isErrorPage="true"%> <html> <head> <title>Error.jsp</title> </head> <body> Your page generate an Exception. <br> <%= exception.getMessage() %> </body> </html> http://www.java2all.com
  • 20. Web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <error-page> <exception- type>java.lang.NumberFormatException</exce ption-type> <location>/Error.jsp</location> </error-page> </web-app> http://www.java2all.com
  • 21. NOTE : web.xml (deployment descriptor) file is available in WEB-INF folder at WebRoot. Input the integer value in textfields and click ADD button. The browser display the below message, Addition = 11 Now, input the float value in any of the textfield and click ADD button so the browser display the message, http://www.java2all.com
  • 22. Your page generates an Exception. For input string: "6.3“ This deployment descriptor entry means that whenever a web component throws a NumberFormatException from any web page in the whole application(web project), the web container call the Error.jsp file, which simply reports the error message in web browser. http://www.java2all.com