org.apache.struts2.dispatcher
Class ServletDispatcherResult

java.lang.Object
  extended by org.apache.struts2.dispatcher.StrutsResultSupport
      extended by org.apache.struts2.dispatcher.ServletDispatcherResult
All Implemented Interfaces:
Result, Serializable, StrutsStatics

public class ServletDispatcherResult
extends StrutsResultSupport

Includes or forwards to a view (usually a jsp). Behind the scenes Struts will use a RequestDispatcher, where the target servlet/JSP receives the same request/response objects as the original servlet/JSP. Therefore, you can pass data between them using request.setAttribute() - the Struts action is available.

There are three possible ways the result can be executed:

This result type takes the following parameters: Example:

 <result name="success" type="dispatcher">
   <param name="location">foo.jsp</param>
 </result>
 
This result follows the same rules from StrutsResultSupport.

See Also:
RequestDispatcher, Serialized Form

Field Summary
 
Fields inherited from class org.apache.struts2.dispatcher.StrutsResultSupport
DEFAULT_PARAM
 
Fields inherited from interface org.apache.struts2.StrutsStatics
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION, STRUTS_PORTLET_CONTEXT
 
Constructor Summary
ServletDispatcherResult()
           
ServletDispatcherResult(String location)
           
 
Method Summary
 void doExecute(String finalLocation, ActionInvocation invocation)
          Dispatches to the given location.
 void setUrlHelper(UrlHelper urlHelper)
           
 
Methods inherited from class org.apache.struts2.dispatcher.StrutsResultSupport
conditionalParse, execute, getLastFinalLocation, getLocation, setEncode, setLocation, setParse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletDispatcherResult

public ServletDispatcherResult()

ServletDispatcherResult

public ServletDispatcherResult(String location)
Method Detail

setUrlHelper

public void setUrlHelper(UrlHelper urlHelper)

doExecute

public void doExecute(String finalLocation,
                      ActionInvocation invocation)
               throws Exception
Dispatches to the given location. Does its forward via a RequestDispatcher. If the dispatch fails a 404 error will be sent back in the http response.

Specified by:
doExecute in class StrutsResultSupport
Parameters:
finalLocation - the location to dispatch to.
invocation - the execution state of the action
Throws:
Exception - if an error occurs. If the dispatch fails the error will go back via the HTTP request.


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.