• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem configuring Error Page

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am trying to configure an errorPage, but it's not working...
below is code for my web.xml, errorPage.jsp.

--------------------------------------------------------------------
web.xml

<web-app
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/web-app_2_4.xsd" version="2.4">

<description>
JSP 2.0 Examples.
</description>
<display-name>JSP 2.0 Examples</display-name>

<error-page>
<exception-type>java.lang.throwable</exception-type>
<location>/errorPage.jsp</location>
</error-page>

<error-page>
<error-code>404</error-code>
<location>/errorPage.jsp</location>
</error-page>
</web-app>

------------------------------------------------------------
errorPage.jsp

<%@ page isErrorPage="true" %>
<html><body>
<h1> Sorry!! There is a problem... </h1>
</body></html>

-----------------------------------

now, I tried it with a simple jsp, below is the code for that

badPage.jsp
------------------------------------
<html<body>
<H1> Hello!!! <br> Welcome to my Page </h1>
<BR><A Href="Each.jsp" >Each</A>
</body></html>
------------------------------------------

The link Each refers to a page that doesnot exist, so after clicking on the link, the error page should appear... but problem is that, it is showing the usual "The page cannot be found" page....
I added <%@ page errorPage="errorPage.jsp" %> in the badPage.jsp, but even that is not working...
I would really appriciate any help...

Regards,
Sushma
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sharma,

I've try u'r problem with the same setting in web.xml and it work well.
It displays errorPage.jsp configured on :
<error-page>
<error-code>404</error-code>
<location>/errorPage.jsp</location>
</error-page>

I use Tomcat 5 for testing.

rgds,
WYasa
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even I tried the same as Sushma... but even I'm not able to get errorPage.jsp on clicking a link to a file which does not exit..
I too used tomcat 5.
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Your quote

The link Each refers to a page that doesnot exist, so after clicking on the link, the error page should appear... but problem is that, it is showing the usual "The page cannot be found" page....



Some browsers display their own customized page for the error codes (Status code set in the response header).

Try to test in another browser like FireFox.

Thanks
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In your code


The exception type should be java.lang.Throwable

Thanks
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get the "The page cannot be found" message in my browser. Is this browser specific ?

IE 6.0 / Tomcat5.0.30 / Win XP

Included this in web.xml
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi PNS,

Yes it is browser Specific. The IE display it's own Page. It shows the Page not Found heading and lot of option to try.

Try to run the same example in FireFox 1.3 ( that I am using), It will display the proper errorPage.jsp page.

Thanks
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Narendra,

Thanks a lot for your advice. I tried the same page in Netscape and it works fine...

Regards,

Sushma
 
AmitKumar Jain
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends!!

I just discovered that if you can get the same result in Internet Explorer..if you uncheck the option "Show friendly HTTP Error Messages" from Tools->Internet Options-> Advanced-> Browsing .
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all - it was a case of having the setting changed in IE as described above.
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I tried amit's suggestion. Now, when I click on my Each link, it doesn't give me that internet explorer's "The Page can not be Found" page, But, now it shows me
HTTP Status - 404 error that "the requested resource (/Each.jsp) is not available." that is, the message tomcat gives when a resource is unavailable... It is still not going to my error page...

Regards,

Sushma
 
AmitKumar Jain
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used IE6.0 and tomcat 5.0 . I hope ur using the same..
I think now in ur case problem is not with IE but with ur tomcat version. download the latest ver and try again.
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit,

I am also using IE6 and tomcat5.0.28...

Regards,

Sushma
 
reply
    Bookmark Topic Watch Topic
  • New Topic