Index: stripes/src/net/sourceforge/stripes/action/RedirectResolution.java =================================================================== --- stripes/src/net/sourceforge/stripes/action/RedirectResolution.java (revision 970) +++ stripes/src/net/sourceforge/stripes/action/RedirectResolution.java (revision ) @@ -45,6 +45,7 @@ */ public class RedirectResolution extends OnwardResolution implements Resolution { private static final Log log = Log.getInstance(RedirectResolution.class); + private boolean permanent; private boolean prependContext = true; private boolean includeRequestParameters; private Collection beans; // used to flash action beans @@ -107,6 +108,18 @@ } /** + * Indicates whether the redirect should be a permanent redirect (HTTP status code 301) instead + * of a temporary redirect (the default). + * + * @param permanent Whether the redirect should be a permanent redirect. + * @return RedirectResolution, this resolution so that methods can be chained + */ + public RedirectResolution setPermanent(boolean permanent) { + this.permanent = permanent; + return this; + } + + /** * If set to true, will cause absolutely all request parameters present in the current request * to be appended to the redirect URL that will be sent to the browser. Since some browsers * and servers cannot handle extremely long URLs, care should be taken when using this @@ -175,6 +188,11 @@ url = response.encodeRedirectURL(url); log.trace("Redirecting ", this.beans == null ? "" : "(w/flashed bean) ", "to URL: ", url); + if (permanent) { + response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); + response.setHeader("Location", url); + } else { - response.sendRedirect(url); - } -} + response.sendRedirect(url); + } + } +}