Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Error Page in JSP Having Problems.

  1. #1
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    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
    <%@ 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
    <%@ 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
    <?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
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Unhappy Re: Error Page in JSP Having Problems.

    Attaching eclipse structure...
    Attached Images Attached Images

Similar Threads

  1. reg how to use log in jsp page
    By javaking in forum JavaServer Pages: JSP & JSTL
    Replies: 7
    Last Post: April 9th, 2010, 12:36 AM
  2. Need help in JSP Page
    By vinothkumarrvk in forum Web Frameworks
    Replies: 1
    Last Post: March 12th, 2010, 07:43 AM
  3. Problem in JSP Page Designing
    By vinothkumarrvk in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: March 10th, 2010, 01:09 AM
  4. Need help in JSP Page
    By vinothkumarrvk in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: March 9th, 2010, 05:20 AM
  5. Replies: 1
    Last Post: June 21st, 2009, 11:05 AM