คุณสมบัติ
| แอตทริบิวต์ | คำอธิบาย | จำเป็น | ค่าเริ่มต้น |
|---|---|---|---|
| var | ชื่อของตัวแปรที่จะเก็บ java.lang.Throwable หากโยนโดยองค์ประกอบในเนื้อหา | ไม่ | ไม่มี |
ตัวอย่าง
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<html>
<head>
<title><c:catch> Tag Example</title>
</head>
<body>
<c:catch var ="catchException">
<% int x = 5/0;%>
</c:catch>
<c:if test = "${catchException != null}">
<p>The exception is : ${catchException} <br />
There is an exception: ${catchException.message}</p>
</c:if>
</body>
</html> รหัสข้างต้นจะสร้างผลลัพธ์ดังต่อไปนี้ -
The exception is : java.lang.ArithmaticException: / by zero There is an exception: / by zero