• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Catching exception issue...

 
Carmen Brianick
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, for some reason the code below always outputs the catch-all errorPage.jsp when it should output arithmeticException.jsp b/c I do ${10/0}. Can anyone see my error?

Thanks so much,
Carmen.

<html><body>
About to be bad...
<% int x = 10/0; %>
</body></html>


<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/arithmeticErrorPage.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/errorPage.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/notFoundError.jsp</location>
</error-page>
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Tested Using Tomcat 5.5.7.
Show the error page releted to Throwable. But it the <exception-type>java.lang.Throwable </exception-type> removed form web.xml,show the page related to Arithmetic Exception.

Working perfectly with Sun Java System Application Server 8.1, with both entries. Properly shows the page related to ArithmeticException.

Thanks
 
Radhika Gokhale
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So does this mean that the order in which exceptions are handled is container specific

Radhika
 
Carmen Brianick
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narendra!, thanks for your help, I'll redo it, I have Tomcat 5.0.28.

Thanks so much,
Carmen
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Radhika,

So does this mean that the order in which exceptions are handled is container specific


The order is not important for any container. It is problem of supertype and sub-type of Exceptions. The above results are same for any order entries for <error-page>

Thanks
 
Yogesh Hingmire
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narendra,

From what i understand is the behaviour is different for different containers.
What should be the answer when confronted with such a question at the actual exam?

Yogesh
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You should go by Specs. It says it select the closest match.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic