private boolean sendErrorPage(String location, Response response) { File file = new File(location); if (!file.isAbsolute()) { file = new File(getContainer().getCatalinaBase(), location); } if (!file.isFile() || !file.canRead()) { getContainer().getLogger().warn( sm.getString("errorReportValve.errorPageNotFound", location)); return false; } // Hard coded for now. Consider making this optional. At Valve level or // page level? response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); try (OutputStream os = response.getOutputStream(); InputStream is = new FileInputStream(file);){ IOTools.flow(is, os); } catch (IOException e) { getContainer().getLogger().warn( sm.getString("errorReportValve.errorPageIOException", location), e); return false; } return true; }
private boolean sendErrorPage(String location, Response response) { File file = new File(location); if (!file.isAbsolute()) { file = new File(getContainer().getCatalinaBase(), location); } if (!file.isFile() || !file.canRead()) { getContainer().getLogger().warn( sm.getString("errorReportValve.errorPageNotFound", location)); return false; } // Hard coded for now. Consider making this optional. At Valve level or // page level? response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); try (OutputStream os = response.getOutputStream(); InputStream is = new FileInputStream(file);){ IOTools.flow(is, os); } catch (IOException e) { getContainer().getLogger().warn( sm.getString("errorReportValve.errorPageIOException", location), e); return false; } return true; }