In this example we are going to catch an exception by using the EL. We can't prevent errors, but of course we can give the user a friendlier error response page. Instead of giving any error codes we should try to show some friendly messages.
In this example we are going to catch an exception using EL in the page where we are going to catch the exception.
The code of the program is given below:
| <%@ page errorPage = "ErrorPageOfJstl.jsp"%> <html> <head> <title>Throwing an Exception</title> </head> <body>5 divided by 0 is <% int x = 5/0;%> </body> </html> |
| <%@ page isErrorPage = "true"%> <html> <body> <img src = "/tapan/jsp/jspexamples/fruit.gif"><br> You caused an exception ${pageContext.exception} on the server. </body> </html> |
The output of the program is given below:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Catch an Exception using EL
Post your Comment