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); } }
@Override public String getRequestURI() { String contextPath = getContextPath(); if ("/".equals(contextPath)) { contextPath = ""; } return contextPath + (servletPath + pathInfo).replace("//", "/"); }
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); } }
@Override public String getRequestURI() { String contextPath = getContextPath(); if ("/".equals(contextPath)) { contextPath = ""; } return contextPath + (servletPath + pathInfo).replace("//", "/"); }