Forums Register Login

response.sendError & error-page

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
Climb the rope! CLIMB THE ROPE! You too tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4683 times.
Similar Threads
error-page
tomcat 5 and error page
error page under WEB-INF
Jsp error page handling
tomcat 5 and error page
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 23:37:27.