• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Catching exception issue...

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
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,

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
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

Thanks
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic