JSTL - jstl core catch
<prefix:catch> ये tag Throwable exceptions को catch करने के लिए इस्तेमाल किया जाता है | इस tag का इस्तेमाल Exception Handling में किया जाता है |
Syntax for <prefix:catch> in JSTL
<prefix:catch var ="variable_name"> Statements; </prefix:catch>
<prefix:catch> Attribute in JSTL
var : इस attribute के variable name पर exception को store किया जाता है |
Example for <prefix:catch> Tag in JSTL
Source Code :Output :<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:catch var ="e"> <% int a = 5; int b = 0; int c = a/b; %> </c:catch> <c:if test = "${e != null}"> Exception occured : ${e} </c:if>
Exception occured : java.lang.ArithmeticException: / by zero