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

response.sendError & error-page

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem with catching error page

When I throw an Throwable exception everything works fine (my error-page, defined in the DD catches it)

but if do response.sendError(404) in my servlet code my error-page doesn't catches it..

here's the source:

DD:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/jsp/ch11/Error.jsp</location>
</error-page>

<error-page>
<exception-type>404</exception-type>
<location>/jsp/ch11/Error.jsp</location>
</error-page>

Servlet's doGet method (that invokes the error)

//throw new IOException("asd "); //works OK, Error.jsp catches it
response.sendError(404); // see HTTP Status 404, not my Error.jsp

Thank you for your time
 
Andriy Fedotov
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry guys, i found out what was the problem.

for http errors like 404 i should have used <error-code> in the <error-page>

so,

<error-page>
<error-code>404</error-code>
<location>/jsp/ch11/Error.jsp</location>
</error-page>

works well
 
We can walk to school together. And we can both read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic