
- Basic JSP Tutorial
- JSP - Home
- JSP - Overview
- JSP - Environment Setup
- JSP - Architecture
- JSP - Lifecycle
- JSP - Syntax
- JSP - Directives
- JSP - Actions
- JSP - Implicit Objects
- JSP - Client Request
- JSP - Server Response
- JSP - Http Status Codes
- JSP - Form Processing
- JSP - Writing Filters
- JSP - Cookies Handling
- JSP - Session Tracking
- JSP - File Uploading
- JSP - Handling Date
- JSP - Page Redirect
- JSP - Hits Counter
- JSP - Auto Refresh
- JSP - Sending Email
- Advanced JSP Tutorials
- JSP - Standard Tag Library
- JSP - Database Access
- JSP - XML Data
- JSP - Java Beans
- JSP - Custom Tags
- JSP - Expression Language
- JSP - Exception Handling
- JSP - Debugging
- JSP - Security
- JSP - Internationalization
- JSP Useful Resources
- JSP - Questions and Answers
- JSP - Quick Guide
- JSP - Useful Resources
- JSP - Discussion
JSTL - Core <c:catch> Tag
The <c:catch> tag catches any Throwable that occurs in its body and optionally exposes it. It is used for error handling and to deal more gracefully with the problem.
Attribute
The <c:catch> tag has the following attributes −
Attribute | Description | Required | Default |
---|---|---|---|
var | The name of the variable to hold the java.lang.Throwable if thrown by elements in the body. | No | None |
Example
<%@ 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 above code will generate the following result −
The exception is : java.lang.ArithmaticException: / by zero There is an exception: / by zero
jsp_standard_tag_library.htm
Advertisements