@Test(groups = "fast") public void testTemporaryRedirect() throws Exception { RedirectResolution resolution = new RedirectResolution("http: MockHttpServletResponse response = new MockHttpServletResponse(); resolution.execute(buildMockServletRequest(), response); Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_MOVED_TEMPORARILY); Assert.assertEquals(response.getRedirectUrl(), "http: }
@SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new HttpServletResponseWrapper(response) { @Override public void setStatus(int sc) { } @Override public void sendRedirect(String location) throws IOException { setHeader("Location", location); } }; } if (this.includeRequestParameters) { addParameters(request.getParameterMap()); } if (this.beans != null) { FlashScope flash = FlashScope.getCurrent(request, true); for (ActionBean bean : this.beans) { flash.put(bean); } } FlashScope flash = FlashScope.getCurrent(request, false); if (flash != null) { addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, flash.key()); } String url = getUrl(request.getLocale()); if (prependContext) { String contextPath = request.getContextPath(); if (contextPath.length() > 1) { url = contextPath + url; } } url = response.encodeRedirectURL(url); log.trace("Redirecting ", this.beans == null ? "" : "(w/flashed bean) ", "to URL: ", url); response.sendRedirect(url); AsyncResponse asyncResponse = AsyncResponse.get(request); if (asyncResponse != null) { asyncResponse.complete(); } }
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new HttpServletResponseWrapper(response) { @Override public void setStatus(int sc) { } @Override public void sendRedirect(String location) throws IOException { setHeader("Location", location); } }; } if (this.includeRequestParameters) { addParameters(request.getParameterMap()); } if (this.beans != null) { FlashScope flash = FlashScope.getCurrent(request, true); for (ActionBean bean : this.beans) { flash.put(bean); } } FlashScope flash = FlashScope.getCurrent(request, false); if (flash != null) { addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, flash.key()); } String url = getUrl(request.getLocale()); if (prependContext) { String contextPath = request.getContextPath(); if (contextPath.length() > 1) { url = contextPath + url; } } url = response.encodeRedirectURL(url); log.trace("Redirecting ", this.beans == null ? "" : "(w/flashed bean) ", "to URL: ", url); response.sendRedirect(url); AsyncResponse asyncResponse = AsyncResponse.get(request); if (asyncResponse != null) { asyncResponse.complete(); } } }
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new HttpServletResponseWrapper(response) { @Override public void setStatus(int sc) { } @Override public void sendRedirect(String location) throws IOException { setHeader("Location", location); } }; } if (this.includeRequestParameters) { addParameters(request.getParameterMap()); } if (this.beans != null) { FlashScope flash = FlashScope.getCurrent(request, true); for (ActionBean bean : this.beans) { flash.put(bean); } } FlashScope flash = FlashScope.getCurrent(request, false); if (flash != null) { addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, flash.key()); } String url = getUrl(request.getLocale()); if (prependContext) { String contextPath = request.getContextPath(); if (contextPath.length() > 1) { url = contextPath + url; } } url = response.encodeRedirectURL(url); log.trace("Redirecting ", this.beans == null ? "" : "(w/flashed bean) ", "to URL: ", url); response.sendRedirect(url); AsyncResponse asyncResponse = AsyncResponse.get(request); if (asyncResponse != null) { asyncResponse.complete(); } } RedirectResolution(String url);  RedirectResolution(String url, boolean prependContext);  RedirectResolution(Class<? extends ActionBean> beanType);  RedirectResolution(Class<? extends ActionBean> beanType, String event); }
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new HttpServletResponseWrapper(response) { @Override public void setStatus(int sc) { } @Override public void sendRedirect(String location) throws IOException { setHeader("Location", location); } }; } if (this.includeRequestParameters) { addParameters(request.getParameterMap()); } if (this.beans != null) { FlashScope flash = FlashScope.getCurrent(request, true); for (ActionBean bean : this.beans) { flash.put(bean); } } FlashScope flash = FlashScope.getCurrent(request, false); if (flash != null) { addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, flash.key()); } String url = getUrl(request.getLocale()); if (prependContext) { String contextPath = request.getContextPath(); if (contextPath.length() > 1) { url = contextPath + url; } } url = response.encodeRedirectURL(url); log.trace("Redirecting ", this.beans == null ? "" : "(w/flashed bean) ", "to URL: ", url); response.sendRedirect(url); AsyncResponse asyncResponse = AsyncResponse.get(request); if (asyncResponse != null) { asyncResponse.complete(); } } RedirectResolution(String url);  RedirectResolution(String url, boolean prependContext);  RedirectResolution(Class<? extends ActionBean> beanType);  RedirectResolution(Class<? extends ActionBean> beanType, String event); @Override String getAnchor(); @Override RedirectResolution setAnchor(String anchor); RedirectResolution includeRequestParameters(boolean inc); RedirectResolution flash(ActionBean bean); @SuppressWarnings("unchecked") @Override void execute(HttpServletRequest request, HttpServletResponse response); RedirectResolution setPermanent(boolean permanent); }
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new HttpServletResponseWrapper(response) { @Override public void setStatus(int sc) { } @Override public void sendRedirect(String location) throws IOException { setHeader("Location", location); } }; } if (this.includeRequestParameters) { addParameters(request.getParameterMap()); } if (this.beans != null) { FlashScope flash = FlashScope.getCurrent(request, true); for (ActionBean bean : this.beans) { flash.put(bean); } } FlashScope flash = FlashScope.getCurrent(request, false); if (flash != null) { addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, flash.key()); } String url = getUrl(request.getLocale()); if (prependContext) { String contextPath = request.getContextPath(); if (contextPath.length() > 1) { url = contextPath + url; } } url = response.encodeRedirectURL(url); log.trace("Redirecting ", this.beans == null ? "" : "(w/flashed bean) ", "to URL: ", url); response.sendRedirect(url); AsyncResponse asyncResponse = AsyncResponse.get(request); if (asyncResponse != null) { asyncResponse.complete(); } } RedirectResolution(String url);  RedirectResolution(String url, boolean prependContext);  RedirectResolution(Class<? extends ActionBean> beanType);  RedirectResolution(Class<? extends ActionBean> beanType, String event); @Override String getAnchor(); @Override RedirectResolution setAnchor(String anchor); RedirectResolution includeRequestParameters(boolean inc); RedirectResolution flash(ActionBean bean); @SuppressWarnings("unchecked") @Override void execute(HttpServletRequest request, HttpServletResponse response); RedirectResolution setPermanent(boolean permanent);  }