asked in JSP by (58.6k points)

1 Answer

We can use JSTL Core tags c:catch and c:if to catch exception inside the JSP service method and process it. c:catch tag catches the exception and wraps it into the exception variable and we can use c:if condition tag to process it. Below code snippet provide sample usage.

<c:catch var ="exception">
   <% int x = 5/0;%>
</c:catch>
 
<c:if test = "${exception ne null}">
   <p>Exception is : ${exception} 

   Exception Message: ${exception.message}</p>
</c:if>
answered by (58.6k points)

Java Interview Questions and Answers 2018

>
...