Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Exception Handling

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to define an error-page in web.xml like
<error-page>
<exception-type>MyException</exception-type>
<location>/jsp/errorpage.jsp</location>
</error-page>
In my servlet code, doGet throws a MyException (which extends ServletException).
I really thought this should go well, but a HTTP 500 - Internal Server error is created.
Is there something wrong in my approach, or what?
TIA,
Ruud.
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you need to provide the fully qualified exception, with package:

Of course, if you're exception isn't in a package, that won't apply.
 
Ruud Steeghs
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, i know, but that wasn't the problem.
problem was that i was using exception.getMessage()
However, the exception is not available as it is in the jsp errorpage.
I have to retrieve the exception from the request via the request.getAttribute("javax.servlet.error.something");
 
My pie came with a little toothpic holding up this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic