Results 1 to 7 of 7
  1. #1
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    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
    Java 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
    Java 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
    Java 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... :confused:

    Goldest

  2. #2
    arun9683 is offline Member
    Join Date
    Jun 2010
    Location
    Bangalore,India
    Posts
    70
    Rep Power
    0

    Default

    make sure both throwError.jsp and your errorPage.jsp are in the same folder.If not give the correct path in the JSP.

    No entry is needed in the web.xml

    just make sure the path of the image your placing in the errorPage.jsp

    Otherthings should work fine...

    :)
    Arun K R,Bangalore,India
    :)

  3. #3
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Unhappy Yes.

    Hi Arun,

    Thanks for the response. Everything is in place... Attaching a snapshot of eclipse structure here as well.

    The settings in web.xml are just to make sure that someway or the other, the error image will get displayed [either by an exception or through error code].

    Please see if you can have this configured at your eclipse if time permits. That would give you a better idea.

    Thanks in advance!

    Goldest
    Attached Thumbnails Attached Thumbnails Error Page in JSP Having Problems.-error_page_structure.jpg  

  4. #4
    arun9683 is offline Member
    Join Date
    Jun 2010
    Location
    Bangalore,India
    Posts
    70
    Rep Power
    0

    Default

    Dont put the code in the declarative tag.

    Put it in the scriplet tag

    Instead of
    <%! int x = 12/0; %>

    put

    <%
    int x = 12/0;
    %>
    Arun K R,Bangalore,India
    :)

  5. #5
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Unhappy No Success...

    Hey Arun,

    Tried your suggestion, but still no success. The same error gets displayed : HTTP 500 Internal Server Error.

    Any other trick to try out?

    Thanks for the response,

    Goldest

  6. #6
    arun9683 is offline Member
    Join Date
    Jun 2010
    Location
    Bangalore,India
    Posts
    70
    Rep Power
    0

    Default

    Its working fine for me..

    Just you try to run the program in Mozilla .. it will show the exact error.

    You post the error.. Hope i can help after seeing the error..
    Arun K R,Bangalore,India
    :)

  7. #7
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Talking Ohh yeah

    Now, this is weird. But I don't know how can this happen? Even I can see the correct output in Mozilla. I am currently using the Eclipse Ganymede. This version gives 4 options of browsers to use.

    • Internal Web Browser
    • Default System Web Browser
    • Internet Explorer
    • Mozilla


    Majority of the times I select "Default system web browser" and it works fine for almost all the applications. This time I don't know what has changed. No other browser options than Mozilla are working for this particular application. The rest of the applications works fine with other browser options as well.

    Thanks Arun, it works in Mozilla. And the error message is the same with other browser options:- "The webpage can't be displayed. HTTP 500 Internal Server Error."

    Anyone having any idea about such weird behavior? Or Any particular setting that I need to do?

    Thanks much,
    Goldest
    Last edited by goldest; 07-19-2010 at 08:36 AM. Reason: Change

Similar Threads

  1. Error while parsing html page in java on linux
    By rdhaware in forum Advanced Java
    Replies: 1
    Last Post: 02-20-2009, 02:20 AM
  2. Replies: 0
    Last Post: 02-16-2009, 08:05 AM
  3. Common error page using struts tiles...?
    By prabhurangan in forum Web Frameworks
    Replies: 0
    Last Post: 08-28-2008, 02:34 PM
  4. problems with my JSP login page
    By ilangocal in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-28-2008, 06:40 PM
  5. problems when I try to execute a jsp page
    By christina in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-01-2007, 12:23 PM

Posting Permissions

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