File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem configuring Error Page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem configuring Error Page" Watch "Problem configuring Error Page" New topic
Author

Problem configuring Error Page

Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
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
Wayan Suwastika
Greenhorn

Joined: May 25, 2005
Posts: 11
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


SCJA, SCJP 1.4, SCWCD inprogress
AmitKumar Jain
Ranch Hand

Joined: Jun 13, 2005
Posts: 95
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.


SCJP 1.4 : 91%
SCWCD 1.4 : 95%
SCBCD 1.3 : 95%
SCJP 6 Upgrade : 95%
Next SCBCD 1.5
Man is not finished when he is defeated. He is finished when he quits.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
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
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

In your code


The exception type should be java.lang.Throwable

Thanks
PNS Subramanian
Ranch Hand

Joined: Jul 13, 2004
Posts: 150
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

Joined: Dec 04, 2004
Posts: 950
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

Joined: Jun 02, 2005
Posts: 139
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

Joined: Jun 13, 2005
Posts: 95
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

Joined: Jul 13, 2004
Posts: 150
Thanks all - it was a case of having the setting changed in IE as described above.
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
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

Joined: Jun 13, 2005
Posts: 95
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

Joined: Jun 02, 2005
Posts: 139
Hi Amit,

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

Regards,

Sushma
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem configuring Error Page
 
Similar Threads
errorPage
problem while declaring error page
error pages in dd
pageContext.exception is not executing
error-page tag facing problem