SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.net
Bhumivaghasiya
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
thinkphp
 

Mais procurados (20)

Session bean
Session beanSession bean
Session bean
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Webservices
WebservicesWebservices
Webservices
 
WSDL
WSDLWSDL
WSDL
 
Servlets
ServletsServlets
Servlets
 
Servlets
ServletsServlets
Servlets
 
jQuery
jQueryjQuery
jQuery
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managers
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.net
 
Js ppt
Js pptJs ppt
Js ppt
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
anatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxanatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptx
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
5 collection framework
5 collection framework5 collection framework
5 collection framework
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 

Semelhante a JSP Error handling

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

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 

Último (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

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