Catch an Exception? : Exceptions « JSTL « Java






Catch an Exception?

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Catch an Exception?</title>
  </head>

  <body>
    <c:catch var="e">
    <c:set var="x" value="10" scope="page" />

    <c:set var="y" value="five" scope="page" />

    10 divided by 0 is 
    <c:out value="${10/0}" />

    <br />
    </c:catch>

    <c:if test="${e!=null}">The caught exception is:
    <c:out value="${e}" />

    <br />
    </c:if>

    <c:if test="${e==null}">No exception was thrown
    <br />
    </c:if>
  </body>
</html>



           
       








JSTL-Exception-Catch.zip( 851 k)

Related examples in the same category

1.JSTL Throw an Exception
2.Catch an Exception in JSTL
3.JSTL Exception: UnCaught Exception
4.JSTL: Catch with if
5.JSTL: catch Exception