December 2002
Intermediate to advanced
288 pages
9h 46m
English
If you discover that
a JSP page frequently throws an exception due to unexpected input or
because an external resource is occasionally unavailable, you should
consider catching the exception in the JSP page using the JSTL
<c:catch>
action. You can then deal with the problem in a more user-friendly
way. Consider this example, in which a JSP page includes an external
resource that is not essential for the application’s
main functionality:
<table bgcolor="lightblue">
<tr>
<td>
<c:catch var="error">
<c:import url="http://www.gefionsoftware.com/jspnews.jsp" />
</c:catch>
<c:if test="${error != null}">
Sorry, the news feed is temporarily unavailable.
</c:if>
</td>
</tr>
</table>By catching the potential exception in the JSP page, a response is generated even when the external resource is unavailable.