Although our demonstration is very successful, and makes you understand how to define the exception handle page (such as: Your ExceptionHandler.jsp) in a normal JSP page, but when the JSP throws exceptions, the information passed to us is not very Useful! To get more useful information, please see: 1: Improve formhandler.jsp as follows:
<%
Int agec;
Try {
Age = Integer.Parseint (Request.GetParameter ("age");
} catch (NUMBERFORMATEXCEPTION E) {
Throw new JSPEXCEPTION ("Please enter a valid integer value!");
}
%> Note: This time we will capture the Numberformatexception class exception, which uses new exceptions (JSPEXCEPTION, which is a JSP-specific class, is a subclass of java.lang.exeception) Pass a message (please enter a valid integer value) we;
2: Improve the ExceptionHandler.jsp as follows: That is changed to
<% = exception.getMessage ()%>
font> Ok, try again: What results ??? Is the please entry a valid integer value! pull!!