org.riotfamily.common.web.controller
Class RedirectController

java.lang.Object
  extended by org.riotfamily.common.web.controller.RedirectController
All Implemented Interfaces:
Controller

public class RedirectController
extends Object
implements Controller

Controller that sends a redirect to a configurable URL.


Constructor Summary
protected RedirectController()
           
  RedirectController(String url)
           
  RedirectController(String url, boolean addContextPath, boolean addServletMapping)
           
 
Method Summary
protected  void appendParameters(StringBuffer targetUrl, HttpServletRequest request)
           
protected  String getDestination(HttpServletRequest request)
           
 ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
           
protected  void sendRedirect(HttpServletRequest request, HttpServletResponse response, String targetUrl)
          Send a redirect back to the HTTP client
 void setAddContextPath(boolean contextRelative)
           
 void setAddServletMapping(boolean addServletMapping)
           
 void setEncodingScheme(String encodingScheme)
          Set the encoding to be used for parameter values.
 void setHttp10Compatible(boolean http10Compatible)
          Set whether to stay compatible with HTTP 1.0 clients.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RedirectController

public RedirectController(String url)

RedirectController

public RedirectController(String url,
                          boolean addContextPath,
                          boolean addServletMapping)

RedirectController

protected RedirectController()
Method Detail

setHttp10Compatible

public void setHttp10Compatible(boolean http10Compatible)
Set whether to stay compatible with HTTP 1.0 clients.

In the default implementation, this will enforce HTTP status code 302 in any case, i.e. delegate to HttpServletResponse.sendRedirect. Turning this off will send HTTP status code 303, which is the correct code for HTTP 1.1 clients, but not understood by HTTP 1.0 clients.

Many HTTP 1.1 clients treat 302 just like 303, not making any difference. However, some clients depend on 303 when redirecting after a POST request; turn this flag off in such a scenario.

See Also:
HttpServletResponse.sendRedirect(java.lang.String)

setAddContextPath

public void setAddContextPath(boolean contextRelative)

setAddServletMapping

public void setAddServletMapping(boolean addServletMapping)

setEncodingScheme

public void setEncodingScheme(String encodingScheme)
Set the encoding to be used for parameter values.


handleRequest

public ModelAndView handleRequest(HttpServletRequest request,
                                  HttpServletResponse response)
                           throws Exception
Specified by:
handleRequest in interface Controller
Throws:
Exception

getDestination

protected String getDestination(HttpServletRequest request)

appendParameters

protected void appendParameters(StringBuffer targetUrl,
                                HttpServletRequest request)
                         throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

sendRedirect

protected void sendRedirect(HttpServletRequest request,
                            HttpServletResponse response,
                            String targetUrl)
                     throws IOException
Send a redirect back to the HTTP client

Parameters:
request - current HTTP request (allows for reacting to request method)
response - current HTTP response (for sending response headers)
targetUrl - the target URL to redirect to
Throws:
IOException - if thrown by response methods