Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

Struts Forward Action Example

In this section we will learn about Struts ForwardAction (org.apache.struts.actions.ForwardAction). The ForwardAction is one of the Built-in Actions that is shipped with struts framework.


Struts 2 Tutorial and Examples Struts General Availability - released Login form in Struts2 version 2.3.16 Struts 2 Login Application Struts 2 version released Struts 2 version released Struts 2 Hello World Annotation Example Struts Roseindia Struts 2 Tutorial: Easy steps to learn Struts 2 Difference between Struts and Spring Apache Struts launched to fix vulnerable Feature Struts2 Application in Eclipse: Running the application in Eclipse IDE Struts 2 Hello World Application using Eclipse Interceptors in Struts 2 Struts 2 Action Tag Struts 2 in Agile Development Environment Struts 2 UI Tags Generic Tags Creating own Interceptor What are Interceptors in Struts 2 and how do they work? Results Value Stack / OGNL Action in Struts 2 Framework Struts 2 Interceptors Struts Maven - How to use Maven dependency of Struts Download Struts How Struts 2 Framework works? Architecture of Struts 2 Framework Features and Enhancements in Struts Struts 2 Tutorials - Struts version Struts 1 Tutorial and example programs Struts Tutorial What is Struts Struts Flow Diagram Step By Step Struts Tutorial Struts 2 Login Form Example Struts Video Tutorials Struts 2 Hello World Example Introduction to Struts 2 Framework Downloading and Installing Struts 2.3.8 In Struts What is Model? What is Struts? Download Struts What is Struts Framework? Struts Framework Latest Version of Struts Framework Downloading Struts Official example Struts 2.3.8 released with new features Struts 2.3.8 Tutorials and Examples Hibernate4 Struts Integration

Struts Forward Action Example


In this section we  will learn about Struts ForwardAction (org.apache.struts.actions.ForwardAction). The ForwardAction is one of the Built-in Actions that is shipped with struts framework.

The org.apache.struts.actions.ForwardAction class enables a user to forward request to the specified URL. ForwardAction is an utility classs that is used in cases where a user simply needs to forward the control to an another JSP page. Linking directly a JSP  to an another, violates the MVC principles.  So we achieve this  through  action-mapping. Note that we do not  create any action class. With ForwardAction , simply create an action mapping  in the Strut Configuration and specify the location where the action will forward the request..

Here in this example you will learn more about Struts Forward Action that will help you in grasping the concept better.

No need to develop an Action Class

Developing the Action Mapping in the struts-config.xml

Create seperate action-mapping , for each page you want to link.. Note that the "type" attribute  always take "org.apache.struts.actions.ForwardAction" value. Here  "parameter" attribute specifies the URL to which  the request is  forwarded .



Developing a jsp page

Code of the jsp (ForwardAction.jsp)  to forward request to a different jsp page :

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> 
<html:html locale="true">
<TITLE>Forward Action Example</TITLE>

<H3>Forward Action Example</H3>
<p><html:link page="/">Call the Success page</html:link></p> 

Add the following line in the index.jsp to call the form.

<html:link page="/pages/ForwardAction.jsp">Struts Forward Action</html:link>
Example shows you how to use forward class to forward request to another JSP page.

Building and Testing the Example 

To build and deploy the application go to Struts\Strutstutorial directory and type ant on the command prompt. This will deploy the application. Open the browser and navigate to the ForwardAction.jsp page. Your browser will display the following ForwardAction page.

Selecting  Call the Success page  displays the following Success.jsp page




Share on Google+Share on Google+

Struts Forward Action Example

Posted on: February 22, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Struts Forward Action Example   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
nakul cahudhary
April 18, 2011

December 6, 2011

please provide the code for sending emails via struts application....