Java Reference
In-Depth Information
case, all that we really want to do is display an appropriate error message and then
give the user the opportunity to re-submit the data. However, this program will also
be used to illustrate the use of the implicit JSP object exception (shown in Table 9.1
of Sect. 9.4 ). Though this object would normally be used only within the internal
processing of our JSP, we shall make use of its toString method to display the name
of the exception that has been generated. (This is unlikely to be of any interest to the
user, of course, and would not normally be included in JSP output.) As usual, all
JSP-specifi c code will be shown in bold text…
<!-- NumError.jsp -->
<%@ page isErrorPage="true" %>
<TITLE>Error Page</TITLE>
<CENTER><H3>Data Entry Error<BR><BR>
<FONT COLOR="red"> <%= exception.toString() %>
<FORM METHOD=GET ACTION="SimpleAdderX.html">
<INPUT TYPE="Submit" VALUE="Try again">
The output from SimpleAdderX.html and Adder.jsp will be exactly the same as
that generated by SimpleAdder.html and AdderServlet respectively, of course. Such
output is illustrated in Figs. 8.5 and 8.6 of the previous chapter. An example of the
output generated by NumError.jsp when the user enters a non-numeric value is
shown in Fig. 9.1 .
*** Warning! ***
When Internet Explorer 5.5 onwards is used with Tomcat 5 onwards, the default
action for the browser when it receives an HTTP 500 error code ('Internal server
error') is to display its own (rather unhelpful!) error page, rather than displaying the
JSP error page. In order to correct this default action, it is necessary to amend the
settings in Explorer as indicated below.
1. Select Tools->Internet Options from Explorer's menus.
2. Select the Advanced tab.
Search WWH ::

Custom Search