Home Jsp Simple-jsp-example Catch an Exception using EL



Catch an Exception using EL
Posted on: March 12, 2008 at 12:00 AM
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.

Catch an Exception using EL

        

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:

Download this example.

Related Tags for Catch an Exception using EL:
cexceptionerroreventiouserpageviusingthismessageresponseshowieexamplewherefriendtoexamldshcodeseerrorsdescanliuseulceinfriendlymnttrsagecaadcatchesendagemehowcoursecatxaxamptrysssaspsoessespatanyisivmplpregoeaexceptarcodcodesavinssriteathshostpleplprpreventndodeonomo


More Tutorials from this section

Ask Questions?    Discuss: Catch an Exception using EL  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.