I was not able to get the error page indicated in the web.xml to be displayed when an unAvailableException is thrown in a servlet. My web.xml contains: <error-page> <exception-type> javax.servlet.UnavailableException </exception-type> <location> /MyException.html </location> </error-page> My servlet's doGet() method contains: throw new UnavailableException("Unavailable Exception thrown"); The funny thing is that is u replace UnavailableException with ServletException in both the web.xml and the Servlet code, it works fine. Please help!!!
I believe, if you throw UnavailabeException and specify it in the deployment descriptor, it should work...exactly as you've mentioned in the first post. If it is not working either there some typo or there is a bug. Try <exception-type>javax.servlet.UnavailableException</exception-type> instead of <exception-type> javax.servlet.UnavailableException </exception-type>
Joined: Oct 17, 2000
On a second thought, I agreed with Jim. You original code should be fine. However, there is something particular for the UnavailableExcpetion. Here is what SRV.184.108.40.206 of the 2.3 specification said: "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." If the servlet is released immediately, even before throwing out the Exception object from its doGet() method, this may explain your situation.
Joined: Nov 28, 2001
yeah...that might be it. Try defining another exception that extends from ServletException and see if it works.
Hi, I have also tried MyUnavailableException (a subclass of UnavailableException) and the error page indicated in the deployment descriptor does not show. Instead, the server sends its own 503 Unavailable page. I think that the <error-page> tag in web.xml will not work (ie. the page in <location> tag will not display) when the exception thrown in the servlet is UnavailableException or its subclass. I have been following Java Servlet Programming book and it seems to suggest that the <exception-type> tag works for UnavailableException also. Not too sure. Thanks a lot.