JSTL Core c:catch Tag

JSTL Core c:catch Tag

The JavaServer Pages Standard Tag Library (JSTL) encapsulates core functionality common to many JSP applications. Instead of mixing tags from numerous vendors in your JSP applications, JSTL allows you to employ a single, standard set of tags. This standardization allows you to deploy your applications on any JSP container supporting JSTL and makes it more likely that the implementation of the tags is optimized.

Below is the syntax to include JSTL Core library in your JSP for JSTL Core c:catch Tag:

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

JSTL Core c:catch Tag : Catches any Throwable that occurs in its body and optionally exposes it.The syntax and attributes are as follows with example and ran on server to show you output:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<c:catch var ="exception">
   <% int test = 15/0;%>

<c:if test = "${exception != null}">
  <h2> <p>Exception is : ${exception} <br />
   Exception details: ${exception.message}</p></h2>


JSTL Core c:catch Tag Output:

JSTL Core c:catch Tag

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *