public class RedirectResolution extends OnwardResolution<RedirectResolution> implements Resolution
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.
ForwardResolution
Constructor and Description |
---|
RedirectResolution(java.lang.Class<? extends ActionBean> beanType)
Constructs a RedirectResolution that will redirect to the URL appropriate for
the ActionBean supplied.
|
RedirectResolution(java.lang.Class<? extends ActionBean> beanType,
java.lang.String event)
Constructs a RedirectResolution that will redirect to the URL appropriate for
the ActionBean supplied.
|
RedirectResolution(java.lang.String url)
Simple constructor that takes the URL to which to forward the user.
|
RedirectResolution(java.lang.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(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.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.
|
java.lang.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(java.lang.String anchor)
This method is overridden to make it public.
|
addParameter, addParameters, getParameters, getPath, getUrl, getUrl, setPath, toString
public RedirectResolution(java.lang.String url)
url
- the URL to which the user's browser should be re-directed.public RedirectResolution(java.lang.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(java.lang.Class<? extends ActionBean> beanType)
beanType
- the Class object representing the ActionBean to redirect topublic RedirectResolution(java.lang.Class<? extends ActionBean> beanType, java.lang.String event)
beanType
- the Class object representing the ActionBean to redirect toevent
- the event that should be triggered on the redirectpublic java.lang.String getAnchor()
getAnchor
in class OnwardResolution<RedirectResolution>
public RedirectResolution setAnchor(java.lang.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(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
execute
in interface Resolution
request
- the current HttpServletRequestresponse
- the current HttpServletResponsejavax.servlet.ServletException
- thrown when the Servlet container encounters an errorjava.io.IOException
- thrown when the Servlet container encounters an error? Copyright 2005-2006, Stripes Development Team.