But I understand that this must be respected by the devlopper (us), not the container.
How come the doXXX() method of the servlet where the request is forwarded throws something else then a ServletException or a RuntimeException? This violates the doXXX() declaration of HttpServlet.
With servlets, your first sentence would be true, since we create the code ourselves. But remember this is a
JSP we're forwarding to, and the servlet code for JSPs is
generated by the container. Therefore, in this case the container automatically wraps the original exception in a ServletException which it then throws. So in fact, no violations of the specification occur.
For future reference, note also that this is bad design practise anyway - catching a known exception in a servlet and choosing to forward to another page is not easily maintainable. The better solution is to configure an <error-page> in the deployment descriptor with the <exception-type> subelement set to the appropriate Throwable subclass you want to catch. This causes the container to display a custom error page for any exceptions of this type not caught by any servlets.
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )