1 28 29 package com.caucho.server.webapp; 30 31 import com.caucho.log.Log; 32 33 import javax.servlet.Filter ; 34 import javax.servlet.FilterChain ; 35 import javax.servlet.FilterConfig ; 36 import javax.servlet.ServletException ; 37 import javax.servlet.ServletRequest ; 38 import javax.servlet.ServletResponse ; 39 import java.io.IOException ; 40 import java.util.logging.Logger ; 41 42 45 public class ErrorPageFilter implements Filter { 46 private static final Logger log = Log.open(ErrorPageFilter.class); 47 48 public static String REQUEST_URI = "javax.servlet.include.request_uri"; 49 public static String CONTEXT_PATH = "javax.servlet.include.context_path"; 50 public static String SERVLET_PATH = "javax.servlet.include.servlet_path"; 51 public static String PATH_INFO = "javax.servlet.include.path_info"; 52 public static String QUERY_STRING = "javax.servlet.include.query_string"; 53 54 public static String STATUS_CODE = "javax.servlet.error.status_code"; 55 public static String EXCEPTION_TYPE = "javax.servlet.error.exception_type"; 56 public static String MESSAGE = "javax.servlet.error.message"; 57 public static String EXCEPTION = "javax.servlet.error.exception"; 58 public static String ERROR_URI = "javax.servlet.error.request_uri"; 59 public static String SERVLET_NAME = "javax.servlet.error.servlet_name"; 60 61 public static String JSP_EXCEPTION = "javax.servlet.jsp.jspException"; 62 63 public static String SHUTDOWN = "com.caucho.shutdown"; 64 65 private FilterConfig _config; 66 private Application _app; 67 private ErrorPageManager _errorPageManager; 68 69 72 public ErrorPageFilter() 73 { 74 } 75 76 79 public ErrorPageFilter(ErrorPageManager manager) 80 { 81 _errorPageManager = manager; 82 } 83 84 87 public void init(FilterConfig config) 88 { 89 _config = config; 90 _app = (Application) config.getServletContext(); 91 } 92 93 99 public void doFilter(ServletRequest request, 100 ServletResponse response, 101 FilterChain next) 102 throws ServletException , IOException 103 { 104 try { 105 next.doFilter(request, response); 106 } catch (Throwable e) { 107 _errorPageManager.sendServletError(e, request, response); 108 } 109 } 110 111 114 public void destroy() 115 { 116 } 117 } 118 | Popular Tags |