tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allistair Crossley" <Allistair.Cross...@QAS.com>
Subject RE: Handling exceptions declaratively
Date Mon, 04 Jul 2005 11:48:31 GMT
Hi,

doPost/doGet throw ServletException. I think the problem lies in that you are wrapping your
exception but this does not translate to the exception actually being "of class" UserNotFoundException.
You'd need to actually throw your own exception which could extend ServletException for example.

Cheers, Allistair.

> -----Original Message-----
> From: Carlos Bracho [mailto:carlos.bracho@gmail.com]
> Sent: 04 July 2005 12:37
> To: tomcat-user@jakarta.apache.org
> Subject: Handling exceptions declaratively
> 
> 
> Hello everybody.
> 
> I am trying to handling exceptions declaratively, here is 
> part of my the 
> web.xml file:
> 
> 
> <error-page>
> 
> <exception-type>ladw.model.UserNotFoundException</exception-type>
> 
> <location>/error.jsp</location>
> 
> </error-page>
> 
> <error-page>
> 
> <exception-type>ladw.model.IlegalAccessException</exception-type>
> 
> <location>/error.jsp</location>
> 
> </error-page>
> 
> <error-page>
> 
> <exception-type>ladw.model.InvalidFileNameException</exception-type>
> 
> <location>/error.jsp</location>
> 
> </error-page> 
> 
> <servlet>
> 
> <servlet-name>testServlet</servlet-name>
> 
> <servlet-class>ladw.controller.testServlet</servlet-class>
> 
> </servlet>
> 
> <servlet-mapping>
> 
> <servlet-name>testServlet</servlet-name>
> 
> <url-pattern>/testServlet</url-pattern>
> 
> </servlet-mapping>
> 
> 
> I created a test servlet with the following code:
> 
> 
> /*
> 
> * testServlet.java
> 
> *
> 
> * Created on 3 de julio de 2005, 03:17 PM
> 
> */
> 
>  package ladw.controller;
> 
> 
> import java.io.*;
> 
> import java.net.*;
> 
> import ladw.model.UserNotFoundException;
> 
> import javax.servlet.*;
> 
> import javax.servlet.http.*;
> 
>  public class testServlet extends HttpServlet {
> 
> protected void doGet(HttpServletRequest request, HttpServletResponse 
> response)
> 
> throws ServletException, IOException {
> 
> throw new ServletException("Wrapped UserNotFoundException",new 
> UserNotFoundException()); 
> 
> }
> 
> protected void doPost(HttpServletRequest request, HttpServletResponse 
> response)
> 
> throws ServletException, IOException {
> 
>  }
>  
> }
> 
>  When I write this urL http://localhost:8080/LADW/testServlet 
> in my browser 
> I got the follow error:
> 
>  ladw.model.UserNotFoundException: User does not exist
> 
> ladw.controller.testServlet.doGet(testServlet.java:28)
> 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
> 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
> 
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(
> MonitorFilter.java:362)
> 
>  What is wrong in the error pages declaration??? why the 
> error page does not 
> appear?
> 
> -- 
> ------------------------------------------------------------------
> Carlos J, Bracho M. 
> ------------------------------------------------------------------
> e-mail: carlos.bracho@gmail.com
> MSN: cbrachomi@hotmail.com
> +58 416 409 21 75 
> ------------------------------------------------------------------
> 


<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
-------------------------------------------------------
QAS Ltd.
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message