Code: Select all
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/html/ErrorPage.html</location>
</error-page>
Moderator: admin
Code: Select all
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/html/ErrorPage.html</location>
</error-page>
Actually:admin wrote:As per section 10.9.2, it matches the exact class name of the exception thrown. It doesn't match subclass.
UnavailableException will not be forwarded to ErrorPage.html though, because it is handled by the container before reaching the error page resolution mechanism. The container will probably catch the exception and callServlet Specification 3.0, Section 10.9.2 wrote:The Web application may have declared error pages using the exception-type element. In this case the container matches the exception type by comparing the exception thrown with the list of error-page definitions that use the exception-type element. A match results in the container returning the resource indicated in the location entry. The closest match in the class hierarchy wins.
Code: Select all
response.sendError()
Of course, we can add specific error pages for HTTP status codes:Servlet Specification 3.0, Section 2.3.3.2 wrote:If a permanent unavailability is indicated by the UnavailableException, the servlet container must remove the servlet from service, call its destroy method, and release the servlet instance. Any requests refused by the container by that cause must be returned with a SC_NOT_FOUND (404) response.
If temporary unavailability is indicated by the UnavailableException, the container may choose to not route any requests through the servlet during the time period of the temporary unavailability. Any requests refused by the container during this period must be returned with a SC_SERVICE_UNAVAILABLE (503) response status along with a Retry-After header indicating when the unavailability will terminate.
Code: Select all
<error-page>
<error-code>404</error-code>
<location>/notFound.jsp</location>
</error-page>
<error-page>
<error-code>503</error-code>
<location>/unavailable.jsp</location>
</error-page>
Users browsing this forum: No registered users and 128 guests