What happen my jsp page throws an ArithmeticException I tried it, but it show me tException page, but according to the mock question it should be arException.jsp. I don't know why is that?
-----------------------------------<br />If at first you don't succeed, try again without cry. Everytime You will learn what not to do next time, untill you succeed.<br /> <br />SCJP 1.4 (78%)<br />SCWCD 5 (95%)<br />BICT - UCSC
Originally posted by Chatura Dilan: hello Joy here is the code
The book says: Declaring a catch-all error page This applies to everything in your web app�not just JSPs. You can override it in individual JSPs by adding a page directive with an errorPage attribute.
If you override it, it works.
Sun Certified Associate for Java Platform
Sun Certified Java Programmer 5.0
Sun Certified Web Component Developer 5.0
Joined: Aug 10, 2008
Add errorPage="true" to both the JSP and test the results.
Thanks and Regards Joy
Joined: Feb 13, 2007
I added <%@ page isErrorPage="true" %> to both exception pages, but i get the same results, i don't know why? anyone have this issue? anyway what do we select if we get this kind of question in the exam?
Joined: Dec 29, 2007
Originally posted by Chatura Dilan: I added <%@ page isErrorPage="true" %> to both exception pages, but i get the same results, i don't know why? anyone have this issue? anyway what do we select if we get this kind of question in the exam?
This is wrong. You have to add <%@ page errorPage="arException.jsp" %> in the index.jsp
I think the problem is in Tomcat. In Servlet 2.4 spec you can find:
The Web application may have declared error pages using the exception type element. In this case the container matches the exception type by comparing the exception thrown with the list of error-page definitions that use the exception-type element. A match results in the container returning the resource indicated in the location entry. The closest match in the class hierarchy wins. (page 74)
3. Create also pages witch are in locations tags for example Throwable.jsp <%@ page isErrorPage="true"%> <html> <body> <h1>Throwable</h1> <h4><%= exception %></h4> </body> </html> 4. Run this app in Tomcat and for example in GlassFish
You can comment some declarations of error-page and observe result. GlasFish every time choose the closest exception type for thrower exception, but Tomcat have problem when you declare error-page for exception-type Throwable and Exception. If you haven't it all is also correct.