I have a strange problem when trying to catch Exceptions in my filter. I am supposed 
to run the chain.doFilter() method and catch any exception thereof and handle them in 
the Filter. But even if the Servlets throw a ServletException they are not caught in 
the try - catch block i have set up in the filter. However a 
StringIndexOutOfBoundsException is caught in that block.

 My Filter.doFilter code is below:

 public void doFilter(ServletRequest servletRequest,
         ServletResponse response, FilterChain chain)
         throws IOException, ServletException
     {
             String targetPage = null;
             boolean foundError = false;

             try
             {
                 logger.info(">>>>>>>>>>>> Let the servlet run ");               
                
                 //let the servlet run
                 chain.doFilter(request, response);
                
                 logger.info(">>>>>>>>>>>> In Filter.....This should not be shown ");

             }
             catch (Exception servex)
             {
                 foundError = true;
                   logger.info(">>>>>>>>>>>> Caught exception " + servex);
                
                   //this is unhandled exception. got to system error page
                 targetPage = systemErrorPage;

                 logger.error(servex.getMessage(), servex);
             }

       }



 My servlet doGet() code is simply:

 public void doGet(HttpServletRequest req, HttpServletResponse res)
     throws IOException, ServletException {
        
         String str = "abc";
         //String def = str.substring(5,10);
        
         if(true)
             throw new ServletException("ErrorMessage");
        
     }

 Any ideas?

 Thanks a lot.

 Affan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to