protected void serveStaticContent(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { InputStream is = getResourceAsStream(pathInfo); if (is == null) { throw new ServletException("Static resource " + pathInfo + " is not available"); } try { int ind = pathInfo.lastIndexOf("."); if (ind != -1 && ind < pathInfo.length()) { String type = getStaticResourceContentType(pathInfo.substring(ind + 1)); if (type != null) { response.setContentType(type); } } String cacheControl = getServletConfig().getInitParameter(STATIC_CACHE_CONTROL); if (cacheControl != null) { response.setHeader("Cache-Control", cacheControl.trim()); } ServletOutputStream os = response.getOutputStream(); IOUtils.copyAndCloseInput(is, os); os.flush(); } catch (IOException ex) { throw new ServletException("Static resource " + pathInfo + " can not be written to the output stream"); } }
protected void redirect(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { boolean customServletPath = dispatcherServletPath != null; String theServletPath = customServletPath ? dispatcherServletPath : "/"; ServletContext sc = super.getServletContext(); RequestDispatcher rd = dispatcherServletName != null ? sc.getNamedDispatcher(dispatcherServletName) : sc.getRequestDispatcher((theServletPath + pathInfo).replace("//", "/")); if (rd == null) { String errorMessage = "No RequestDispatcher can be created for path " + pathInfo; if (dispatcherServletName != null) { errorMessage += ", dispatcher name: " + dispatcherServletName; } throw new ServletException(errorMessage); } try { for (Map.Entry<String, String> entry : redirectAttributes.entrySet()) { request.setAttribute(entry.getKey(), entry.getValue()); } HttpServletRequest servletRequest = new HttpServletRequestRedirectFilter(request, pathInfo, theServletPath, customServletPath); if (PropertyUtils.isTrue(getServletConfig().getInitParameter(REDIRECT_WITH_INCLUDE_PARAMETER))) { rd.include(servletRequest, response); } else { rd.forward(servletRequest, response); } } catch (Throwable ex) { throw new ServletException("RequestDispatcher for path " + pathInfo + " has failed", ex); } }
protected void serveStaticContent(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { InputStream is = getResourceAsStream(pathInfo); if (is == null) { throw new ServletException("Static resource " + pathInfo + " is not available"); } try { int ind = pathInfo.lastIndexOf("."); if (ind != -1 && ind < pathInfo.length()) { String type = getStaticResourceContentType(pathInfo.substring(ind + 1)); if (type != null) { response.setContentType(type); } } String cacheControl = getServletConfig().getInitParameter(STATIC_CACHE_CONTROL); if (cacheControl != null) { response.setHeader("Cache-Control", cacheControl.trim()); } ServletOutputStream os = response.getOutputStream(); IOUtils.copyAndCloseInput(is, os); os.flush(); } catch (IOException ex) { throw new ServletException("Static resource " + pathInfo + " can not be written to the output stream"); } }
protected void serveStaticContent(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { InputStream is = getResourceAsStream(pathInfo); if (is == null) { throw new ServletException("Static resource " + pathInfo + " is not available"); } try { int ind = pathInfo.lastIndexOf("."); if (ind != -1 && ind < pathInfo.length()) { String type = getStaticResourceContentType(pathInfo.substring(ind + 1)); if (type != null) { response.setContentType(type); } } String cacheControl = getServletConfig().getInitParameter(STATIC_CACHE_CONTROL); if (cacheControl != null) { response.setHeader("Cache-Control", cacheControl.trim()); } ServletOutputStream os = response.getOutputStream(); IOUtils.copy(is, os); os.flush(); } catch (IOException ex) { throw new ServletException("Static resource " + pathInfo + " can not be written to the output stream"); } }
protected void redirect(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { boolean customServletPath = dispatcherServletPath != null; String theServletPath = customServletPath ? dispatcherServletPath : "/"; ServletContext sc = super.getServletContext(); RequestDispatcher rd = dispatcherServletName != null ? sc.getNamedDispatcher(dispatcherServletName) : sc.getRequestDispatcher((theServletPath + pathInfo).replace("//", "/")); if (rd == null) { String errorMessage = "No RequestDispatcher can be created for path " + pathInfo; if (dispatcherServletName != null) { errorMessage += ", dispatcher name: " + dispatcherServletName; } throw new ServletException(errorMessage); } try { for (Map.Entry<String, String> entry : redirectAttributes.entrySet()) { request.setAttribute(entry.getKey(), entry.getValue()); } HttpServletRequest servletRequest = new HttpServletRequestRedirectFilter(request, pathInfo, theServletPath, customServletPath); if (PropertyUtils.isTrue(getServletConfig().getInitParameter(REDIRECT_WITH_INCLUDE_PARAMETER))) { rd.include(servletRequest, response); } else { rd.forward(servletRequest, response); } } catch (Throwable ex) { throw new ServletException("RequestDispatcher for path " + pathInfo + " has failed", ex); } }
if (PropertyUtils.isTrue(getServletConfig().getInitParameter(REDIRECT_WITH_INCLUDE_PARAMETER))) { rd.include(servletRequest, response); } else {