Custom JSP taglib lets you simplify the processing for the exceptions. Tag catch provides a complement to the JSP error page mechanism. It allows page authors to wrap JSP chunks into catch blocks so possible exceptions will be caught and will never cause the error page mechanism to be invoked. This tag is similar to JSTL core tag catch but provides an additional functionality. The exception thrown could be stored in the page scope variable identified by the parameter var. If no exception occurred this variable is null. And this parameter is optional, so if var is missing, the exception is simply caught and not saved. Optionally you can provide a commas separated list of exceptions that must be caught.
And optional parameter page lets you define a JSP page that could be invoked (additionally to the main page)
in case of caught exception.
For example:
<%@ taglib uri="taglib.tld" prefix="try" %> <try:catch> catch all the exceptions in this code </try:catch>
<%@ taglib uri="taglib.tld" prefix="try" %> <try:catch type="java.lang.IOException"> catch java.lang.IOException in this code </try:catch>
<%@ taglib uri="taglib.tld" prefix="try" %> <try:catch var="A" page="logerror.jsp"> save exception in the variable A and execute logerror.jsp </try:catch> Tags are: catch Body tag catches the exceptions during the execution. Parameters are: 1) var Optional parameter. Describes a name for the page scope variable
(type is java.lang.Exception). This variable will keep caught exception.
for downloading: Library: catchtag.jar Description: taglib.tld See also Coldtags suite - the largest collection of custom JSP tags.
|
Also in Coldtags:
|