@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { try { super.doFilter(req, res, chain); } catch (Exception e) { if(res instanceof HttpServletResponse){ HttpServletResponse response = (HttpServletResponse) res; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An expected error occured!"); } LOGGER.error(e.getMessage(), e); } } }
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { try { super.doFilter(req, res, chain); } catch (Exception e) { if(res instanceof HttpServletResponse){ HttpServletResponse response = (HttpServletResponse) res; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An expected error occured!"); } LOGGER.error(e.getMessage(), e); } } }