Name

<c:catch>

Synopsis

The <c:catch> action catches an exception thrown by JSP elements in its body, providing fine-grained error control. The exception can optionally be saved as a page scope variable.

Syntax

<c:catch [var="var"]>
  JSP elements
</c:catch>

Attributes

Attribute name

Java type

Dynamic value accepted

Description

var
String

No

The variable name

Example

<c:catch var="importException">
  <fmt:parseDate value="${param.empDate}" dateStyle="short" />
</c:catch>
<c:if test="${importException != null}">
  <jsp:forward page="input.jsp">
    <jsp:param name="msg" value="Invalid date format" />
  </jsp:forward>
</c:if>

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.