net.sourceforge.stripes.action
Class ForwardResolution

java.lang.Object
  extended by net.sourceforge.stripes.action.OnwardResolution<ForwardResolution>
      extended by net.sourceforge.stripes.action.ForwardResolution
All Implemented Interfaces:
Resolution

public class ForwardResolution
extends OnwardResolution<ForwardResolution>
implements Resolution

Resolution that uses the Servlet API to forward the user to another path within the same web application using a server side forward.

There is one case when this resolution will issue an include instead of a forward. The Servlet specification is ambiguous about what should happen when a forward is issued inside of an include. The behaviour varies widely by container, from outputting only the content of the forward, to only the content prior to the include! To make this behaviour more consistent the ForwardResolution will automatically determine if it is executing inside of an include, and if that is the case it will include the appropriate URL instead of forwarding to it. This behaviour can be turned off be calling autoInclude(false).

Author:
Tim Fennell
See Also:
RedirectResolution

Constructor Summary
ForwardResolution(Class<? extends ActionBean> beanType)
          Constructs a ForwardResolution that will forward to the URL appropriate for the ActionBean supplied.
ForwardResolution(Class<? extends ActionBean> beanType, String event)
          Constructs a ForwardResolution that will forward to the URL appropriate for the ActionBean supplied.
ForwardResolution(String path)
          Simple constructor that takes in the path to forward the user to.
 
Method Summary
 void autoInclude(boolean auto)
          If true then the ForwardResolution will automatically detect when it is executing as part of a server-side Include and include the supplied URL instead of forwarding to it.
 void execute(HttpServletRequest request, HttpServletResponse response)
          Attempts to forward the user to the specified path.
 
Methods inherited from class net.sourceforge.stripes.action.OnwardResolution
addParameter, addParameters, getAnchor, getParameters, getPath, getUrl, getUrl, setAnchor, setPath, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForwardResolution

public ForwardResolution(String path)
Simple constructor that takes in the path to forward the user to.

Parameters:
path - the path within the web application that the user should be forwarded to

ForwardResolution

public ForwardResolution(Class<? extends ActionBean> beanType)
Constructs a ForwardResolution that will forward to the URL appropriate for the ActionBean supplied. This constructor should be preferred when forwarding to an ActionBean as it will ensure the correct URL is always used.

Parameters:
beanType - the Class object representing the ActionBean to redirect to

ForwardResolution

public ForwardResolution(Class<? extends ActionBean> beanType,
                         String event)
Constructs a ForwardResolution that will forward to the URL appropriate for the ActionBean supplied. This constructor should be preferred when forwarding to an ActionBean as it will ensure the correct URL is always used.

Parameters:
beanType - the Class object representing the ActionBean to redirect to
event - the event that should be triggered on the redirect
Method Detail

autoInclude

public void autoInclude(boolean auto)
If true then the ForwardResolution will automatically detect when it is executing as part of a server-side Include and include the supplied URL instead of forwarding to it. Defaults to true.

Parameters:
auto - whether or not to automatically detect and use includes

execute

public void execute(HttpServletRequest request,
                    HttpServletResponse response)
             throws ServletException,
                    IOException
Attempts to forward the user to the specified path.

Specified by:
execute in interface Resolution
Parameters:
request - the current HttpServletRequest
response - the current HttpServletResponse
Throws:
ServletException - thrown when the Servlet container encounters an error
IOException - thrown when the Servlet container encounters an error


? Copyright 2005-2006, Stripes Development Team.