About Question enthuware.jwpv6.2.1165 :

Moderator: admin

Post Reply
Ambiorix
Posts: 25
Joined: Thu Jan 10, 2013 8:45 am
Contact:

About Question enthuware.jwpv6.2.1165 :

Post by Ambiorix »

I don't see any mention of this in the spec, but does the <exception-type> also match subclasses of the given type, or will it only match the exact exception-type?

Code: Select all

  
<error-page>
     <exception-type>javax.servlet.ServletException</exception-type>
     <location>/html/ErrorPage.html</location>
</error-page>
e.g. will the above forward an UnavailableException to ErrorPage.html, or only ServletExceptions?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1165 :

Post by admin »

As per section 10.9.2, it matches the exact class name of the exception thrown. It doesn't match subclass.
If you like our products and services, please help us by posting your review here.

Viorel Ghelbert
Posts: 15
Joined: Fri Apr 10, 2015 12:53 pm
Contact:

Re: About Question enthuware.jwpv6.2.1165 :

Post by Viorel Ghelbert »

admin wrote:As per section 10.9.2, it matches the exact class name of the exception thrown. It doesn't match subclass.
Actually:
Servlet 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.
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 call

Code: Select all

response.sendError()
with an HTTP status code of 404 or 503:
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.
Of course, we can add specific error pages for HTTP status codes:

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>
HTH,
Viorel

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1165 :

Post by admin »

You are right. I missed that line in the specification. Thank you for correcting.

Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests