Combine If Chooser to Report Exception : Choose « JSTL « Java Tutorial






<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<%
  int i= (int) (Math.random() * 10);
  pageContext.setAttribute("signalStrength", new Integer(i), PageContext.PAGE_SCOPE);
%>

<html>
  <head>
    <title>The c:catch action</title>
  </head>
  <body>
    <c:if test="${pageScope.signalStrength < 5}">
      <c:set var="signalFailure" value="true" scope="page" />
    </c:if>

    <c:choose>
      <c:when test="${pageScope.signalFailure == true}">
        <h3>Exception!</h3>
        Refresh the page in your web browser to try again.
      </c:when>
      <c:otherwise>
        <h3>No Exception.</h3>
        Refresh the page in your web browser to make another call.
      </c:otherwise>
    </c:choose>
  </body>
</html>
  Download:  JSTLCombineIfChooserToReportException.zip( 1,022 k)








24.5.Choose
24.5.1.Tag Examples - choose
24.5.2.Combine If Chooser to Report Exception
24.5.3.Choose XML Data with Comparision
24.5.4.Choose When Statement
24.5.5.Choose When and Otherwise