Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Related Tutorials


 
 

Share on Google+Share on Google+

Catch an Exception using EL

Advertisement
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.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2008

Related Tutorials

Discuss: Catch an Exception using EL  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com