public class RedirectResolution extends OnwardResolution<RedirectResolution>
Resolution that uses the Servlet API to redirect the user to another path by issuing a client side redirect. Unlike the ForwardResolution the RedirectResolution can send the user to any URL anywhere on the web - though it is more commonly used to send the user to a location within the same application.
By default the RedirectResolution will prepend the context path of the web application to
any URL before redirecting the request. To prevent the context path from being prepended
use the constructor: RedirectResolution(String,boolean).
It is also possible to append parameters to the URL to which the user will be redirected. This can be done by manually adding parameters with the addParameter() and addParameters() methods, and by invoking includeRequestParameters() which will cause all of the current request parameters to be included into the URL.
The redirect type can be switched from a 302 temporary redirect (default) to a 301 permanent redirect using the setPermanent method.
ForwardResolution| Constructor and Description |
|---|
RedirectResolution(Class<? extends ActionBean> beanType)
Constructs a RedirectResolution that will redirect to the URL appropriate for
the ActionBean supplied.
|
RedirectResolution(Class<? extends ActionBean> beanType,
String event)
Constructs a RedirectResolution that will redirect to the URL appropriate for
the ActionBean supplied.
|
RedirectResolution(String url)
Simple constructor that takes the URL to which to forward the user.
|
RedirectResolution(String url,
boolean prependContext)
Constructor that allows explicit control over whether or not the context path is
prepended to the URL before redirecting.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute(HttpServletRequest request,
HttpServletResponse response)
Attempts to redirect the user to the specified URL.
|
RedirectResolution |
flash(ActionBean bean)
Causes the ActionBean supplied to be added to the Flash scope and made available
during the next request cycle.
|
String |
getAnchor()
This method is overridden to make it public.
|
RedirectResolution |
includeRequestParameters(boolean inc)
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.
|
RedirectResolution |
setAnchor(String anchor)
This method is overridden to make it public.
|
RedirectResolution |
setPermanent(boolean permanent)
Sets the redirect type to permanent (301) instead of temporary (302).
|
addParameter, addParameters, getEvent, getParameters, getPath, getUrl, getUrl, isEventSpecified, setPath, toStringpublic RedirectResolution(String url)
url - the URL to which the user's browser should be re-directed.public RedirectResolution(String url, boolean prependContext)
url - the URL to which the user's browser should be re-directed.prependContext - true if the context should be prepended, false otherwisepublic RedirectResolution(Class<? extends ActionBean> beanType)
beanType - the Class object representing the ActionBean to redirect topublic RedirectResolution(Class<? extends ActionBean> beanType, String event)
beanType - the Class object representing the ActionBean to redirect toevent - the event that should be triggered on the redirectpublic String getAnchor()
getAnchor in class OnwardResolution<RedirectResolution>public RedirectResolution setAnchor(String anchor)
setAnchor in class OnwardResolution<RedirectResolution>public RedirectResolution includeRequestParameters(boolean inc)
inc - whether or not current request parameters should be included in the redirectpublic RedirectResolution flash(ActionBean bean)
bean - the ActionBean to be added to flash scopepublic void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
request - the current HttpServletRequestresponse - the current HttpServletResponseServletException - thrown when the Servlet container encounters an errorIOException - thrown when the Servlet container encounters an errorpublic RedirectResolution setPermanent(boolean permanent)
© Copyright 2005-2006, Stripes Development Team.