Difference between ForwardAction and IncludeAction

Explain the difference between ForwardAction and IncludeAction.

- Forwarding to a specified URL is provided by the ForwardAction. The mechanism to include the specified URL contents is proveided by the IncludeAction.

- ForwardAction is used to forward to a control from one page to another page / action. IncludeAction is used to include an action in another action.

- ForwardAction is similar to <jsp:forward> and include action is similar to <jsp:include> tags of a JSP page.

Explain the difference between ForwardAction and IncludeAction.

ForwardAction :

- Forwards to the context-relative URI specified by the parameter property of the associated ActionMapping.

- An entry can be created as:
<action
path="/saveSubscription"
type="org.apache. struts.actions.ForwardAction"
name="subscriptionForm"
scope="request"
input="/subscription.jsp"
parameter="/path to processing servlet" />
To configure its use in the struts-config.xml file.

- Steps to use ForwardAction :

- Using the html:link tag with the action attribute, add a link to the JSP page that points to the action.
- Create an Action Mapping in the Struts configuration file that uses the ForwardAction with the parameter attribute to specify the JSP path.

IncludeAction :

- Includes the context-relative URI specified by the parameter property of the associated ActionMapping.

- An entry can be created as:
<action
path="/saveSubscription"
type="org. apache. struts. actions.IncludeAction"
name="subscriptionForm"
scope="request"
input="/subscription.jsp"
parameter="/path to processing servlet">
To configure its use in the struts-config.xml file.

- Use the IncludeAction only if the action is going to be included by another action or JSP. Therefore, if we have code in our JSP that looks like this:

<jsp:include page="/someWebApp/ someModule/someAction.do " />

(a ForwardAction cannot be used here because it would forward control to the new action rather than including its output within the output of the JSP-or throw a nasty IllegalStateException if the output buffer was already committed.)
Difference between Html tags and Struts specific HTML Tags
Difference between Html tags and Struts specific HTML Tags - Most of the tags in the Struts framework use the following attributes...
Contents of web.xml and struts-config.xml
What are the contents of web.xml and struts-config.xml? - The web.xml file contains the information that is used by servlets and JSPs.....
Differences between web.xml and sturts-config.xml
Differences between web.xml and sturts-config.xml - web.xml is utilized to make connections between web application and the web container....
Post your comment