Hi all,
I am having some issues with error pages in JSP.
I am trying to display one simple error image when my JSP is having any kind of error, let’s say when it throws any exception. Here goes the code…
throwError.jsp
Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page errorPage="errorPage.jsp" %>
<html>
<body>
Hello All,
<%! int x = 12/0; %>
</body>
</html>
errorPage.jsp
Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page isErrorPage="true" %>
<html>
<body>
<img src="error.jpg" height="100" width="100">
</body>
</html>
web.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<error-page>
<error-code>500</error-code>
<location>/errorPage.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/errorPage.jsp</location>
</error-page>
</web-app>
Please see if you can help…
Currently when I run the throwError.jsp in Eclipse, nothing happens. It shows "500 Internal server error". But the error.jpg doesn't appear on browser. I have copied the error.jpg properly in the WebContent folder of the Web App root.
Thanks much...
Goldest