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

servlet/jsp exception handling question

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In "MyServlet.java" it invokes some classes which throws out some special exceptions that can be caught in "MyServlet.java". Then some customized exception (subclass of ServletException) is thrown from "Myservlet.java"'s doGet() and doPost() method. Eventually "MyServlet.java" does "forward(req, res)" to send results to "My.jsp" page, I try to catch ALL the exception in "My.jsp" using "errorpage = ..".
But, it seems once the "MyServlet.java" finds any error it goes to a server 500 default page without goes to my special jsp error page. Is it because the exception happened BEFORE the "forward()" ? If so, then how could I make it go to the jsp's special error page ?
Thanks,
Ian
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is. The error page is specified in the JSP and if you haven't yet gone to the JSP, there's simply no way to know what the error page even was.
I don't know if explicitly forwarding to an error page is supported. There's some additional context that has to be provided that ordinary JSP's don't have. However you could provide an ordinary JSP, wrap the doGet/doPost code in a try-catch block and have the catch code forward to that page.
 
reply
    Bookmark Topic Watch Topic
  • New Topic