• 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

Exception: c:catch doubt

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please see what I am trying to do:

In DD:




In errorPage.jsp


In badPage.jsp:



I was assuming the output as :
Inside the catch
There was an exception java.lang.NullPointerException
Output of errorPage.jsp because of exception caused in line #1

But the output is only containing the output from errorPage.jsp as
divide by zero comes. When I remove the code that caused divide by zero
then only the NPE comes. I see the divide by zero exception supersedes the
NPE.
One more thing: Even if I don't write <%@page errorPage ="errorPage.jsp"%>
in the badPage.jsp, it works for divide by zero exception.

I am using apache-tomcat-5.5.23

Please HELP!

Thanks,

[ June 02, 2007: Message edited by: Chandra Bhatt ]

[ June 02, 2007: Message edited by: Chandra Bhatt ]
[ June 02, 2007: Message edited by: Chandra Bhatt ]
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/errorPage.jsp</location>
</error-page>

see the exception type highlighted above..since you are using a ArithmeticException, the errorPage.jsp will be invoked each time a a arithmatic exception ( divide by zero ...in your case) is thrown..

thats why..you are not getting the error page for the null pointer exception..

try using a java.lang.Exception as the exception type...then your errorPage will be a catch all error page

hth
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Niranjan,


Still I am not getting why the previous exception message is not
shown on my web page. As in above case, I am only getting the last exception
caused as divide by zero and the exception I caught inside the catch is lost.
I also tried to define the error page for NPE in DD.

Please put some light on this!


Thanks,
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got It,

Actually the idea didn't come in my head, that the errorPage will be called
dynamically in case exception occurs, so the previous page content will be
superseded by the further page that is called when next exception is
generated.


Note: I didn't write the <%@ page isErrorPage="true"%> on the
top of the errorPage and still it is treated as error page. Can somebody
guide me to understand the issue.


Thanks again!
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is because you are declaring errorpage.jsp in Deployment Descriptor as the official error page to be displayed when an Arithmitic exception is thrown.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool....chandra...happy that things worked..

keep doing !
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Atul,


It means if I define official error page in the DD, and don't add the page
directive <%@ page isErrorPage="true"%> on the errorPage, it will be
treated as errorPage.

It sounds not OK as per it is written in HFSJ page 461 Note: the exception
implicit object is available ONLY to error pages with an explicitly- defined
page directive <%@ page isErrorPage="true"%>



Or I may miss to understand the above note of the HFSJ.

Please confirm!

Thanks Atul for paying attention to this thread!

With Regards,
[ June 03, 2007: Message edited by: Chandra Bhatt ]
 
She'll be back. I'm just gonna wait here. With 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