my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Cannot get <error-page> to work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Cannot get <error-page> to work" Watch "Cannot get <error-page> to work" New topic
Author

Cannot get <error-page> to work

Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

I guess I must be doing something monumentally dumb here, but I just cannot get a simple error page to work.

This is the scenario :
hello.jsp has a "divide by zero" error in it. In the web.xml, java.lang.ArithmeticException is mapped to math.html. But when I access hello.jsp, instead of math.html showing up, The browser just shows a standard Http 500 error.

hello.jsp


web.xml (relevant portion)


Browser error

The website cannot display the page
HTTP 500
Most likely causes:
•The website is under maintenance.
•The website has a programming error.




"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

I've pasted your code and it works fine in my case...

What's your math.html file?
Maybe try to create a new web project. Sometimes if you modify one example and test a lot of things, the web app could become messy very quickly.

Cheers!

Edit: Oh, I did forget - I tested it with tomcat 7, with Servlets 3.0 under the hood.


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Hi Pedro,

I did try creating a new web project just for this, but still the same problem. I have Tomcat 6.0 with servlet 2.5, but that should not matter right? This is pretty elementary.

Nidhi
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Are you using IE ? If yes, go the Internet Options, and turn off the friendly error messages in the Advanced tab. (see this)


[My Blog]
All roads lead to JavaRanch
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Christophe Verré wrote:Are you using IE ? If yes, go the Internet Options, and turn off the friendly error messages in the Advanced tab. (see this)


Yessss. It worked! Thanks Christophe. Hmmm, interesting to remember that while designing a web application, we cannot depend on this behaviour, since the client might have that option checked.
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Didn't use IE in last 5 years, but it's definitely good to know about that!

Thanks Christophe!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot get <error-page> to work
 
Similar Threads
errorPage
pageContext.exception is not executing
Error in simple bean and JSP
Overriding <exception-type> tag in web.xml
<error-page> tag issue