[Q]How to catch Error 404: SRVE0190E

Tooflabbfigt

New Member
I'm trying to capture the 404 error using a filter defined in the web.xml i defined my filter like this \[code\]public class StatusValidationFilter implements Filter{ public void destroy() { // TODO Auto-generated method stub } public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse)servletresponse; if (!(response instanceof StatusExposingServletResponse)) { response = new StatusExposingServletResponse(response); } filterchain.doFilter(servletrequest, response); } public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub }}\[/code\]I defined my wrapper like this:\[code\]public class StatusExposingServletResponse extends HttpServletResponseWrapper { public StatusExposingServletResponse(HttpServletResponse response) { super(response); } public void sendError(int sc) throws IOException { if(sc == HttpServletResponse.SC_NOT_FOUND) { throw new RuntimeException(); } super.sendError(sc); } public void sendRedirect(String location) throws IOException { super.sendRedirect(location); }}\[/code\]Ok, then in the web.xml defined the filter and the mappings like this:\[code\]<filter> <filter-name>StatusValidationFilter</filter-name> <filter-class>com.test.StatusValidationFilter</filter-class></filter><filter-mapping> <filter-name>StatusValidationFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>ERROR</dispatcher></filter-mapping>\[/code\]But is not catching the 404 error, is just calling the filter when the url maps to the url mapped by the ActionServlet, it means, finish with .doI tried changing the property in the WAS com.ibm.ws.webcontainer.invokeFiltersCompatibility=true but still not working and i don't have any else idea of how to fix it, any help will ve appreciated.
 
Top