CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Posts
    8

    Unhappy Error Page in JSP Having Problems.

    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

  2. #2
    Join Date
    Oct 2009
    Posts
    8

    Re: Error Page in JSP Having Problems.

    Attaching eclipse structure...
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured