Oh the dangers of modifying code without first testing it!

I modified that from a plain 'Exception', because I thought I was being
clever. Catch either the exact specific Exceptions that may be thrown (eg:
NullPointer, IO) or just catch 'Exception', as I was originally doing.

-----Original Message-----
From: Héctor Garcia Peris [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 11, 2002 7:25 AM
To: Tomcat Users List
Subject: RE: Change the default error message


At 07:16 11/01/02 -0600, you wrote:
>You could use a JSP error page from a servlet.
>
>Catch any ServletException errors, and do a redirect to your JSP error
page.
>
>Here's short snips from one of my servlets:
>try {
>   //sending email from the servlet...
>} catch (ServletException ex) {
>    log("Failure to send email", ex);
>    sendErrorRedirect(req, res, "/error.jsp", ex);
>}
>
>
>protected void sendErrorRedirect(HttpServletRequest request,
>HttpServletResponse response, String errorPageURL, Throwable e) {
>    try {
>       request.setAttribute ("javax.servlet.jsp.jspException", e);
>
>getServletConfig().getServletContext().getRequestDispatcher(errorPageURL).f
o
>rward(request, response);
>    } catch (Exception ex) {
>       log(getServletName() + ".sendErrorRedirect ", ex);
>    }
>}
>
>
>Hope that helps...


But, I can't catch ServletException. When I try to catch I get the
following message:

EnbreveServlet.java:102: exception javax.servlet.ServletException is never
thrown in body of corresponding try statement
         } catch (ServletException se ) {
           ^



---------------------------------------------------------------------
Héctor Garcia Peris
Dpto. Informática
Instituto Valenciano de Investigaciones Económicas S.A. (Ivie)
C/ Guardia Civil, 22 esc-2 1º 46020 - Valencia (Spain)
Tfno.: +34 - 963190050 / +34 - 963930816
Fax.: +34 - 963190055 / +34 - 963930856
e-mail: [EMAIL PROTECTED]
----------------------------------------------------------------------



--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to