• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

error-page with error-code and jsp

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have web.xml as -

error-page related to IndexOutOfBoundsException works fine.
But error-page related to is not sent to the client. If i use Tp.html instead of Tp.jsp
everything is fine. How to make jsp page work along with error-code. I am using tomcat 5.5.28
Thanks in advance
Regards
 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Sharmila.

Can you please post, what message you are getting when trying to access error generated page?
 
Sharmila Punde
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chinmaya
Tp.jsp code is as bellow -
java.lang.NullPointerException
at org.apache.jsp.Tp$jsp._jspService(Tp$jsp.java:59)

Exception is thrown in out.print( exception.getMessage() ); , because exception object is null.
Why it is not able to get exception object.
Regards

 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Sharmila.

Error codes are not exception's. If our error generated jsp, causes error code 403, then container/server first checks, is there any errorPage directive declared to handle that error? If no, then approaches the web.xml's <error-page> entry, then checks the <error-code>, and if matching found, serves the page. In Tp.jsp, we have declared means the exception implicit object will be available to this jsp. Since there is no exception generated in our error genearated jsp, here exception point's to 'null'. Calling getMessage() on null produces 'NullPointerException'.

Incase of exception generated jsp, if there is any exception generated in the code like (calling 10/0), then container creates exception object(here it is ArithematicException Object) and cathes it. In the catch block it calls the PageContext's handlePageException(t) method by passing the exception object. Then this method will checks is there any 'errorPage' directive declared in the jsp? If yes forward's the request to that jsp. If no, then it approaches the web.xml's <error-page> entry and checks the appropriate exception-type and forwards the request to it. If that page has declared then exception implicit object will be available to the jsp and that exception object is not 'null', since we got 'ArithematicException' in the exception generated jsp and calling getMessage() on it gives '/zero' message.

To be clear see the generated source code and the api of PageContext's handlePageException() method.
 
Sharmila Punde
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chinmaya,
It was very nice and clear and neat explanation. Thanks to point out that error codes are different from exception. I was considering both same. Thank you very much.
Regards

 
Get off me! Here, read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic