Different between ForwardAction and ActionForward



  1. Represents the result pages of struts Action class.


  1. Use forward tags in s-c.xml file to configure action forwards.
 1. A built-in Action class using which the resource of struts application can comm.. with each other through controller servlet called as ActionServlet.2. Use action tag in s-c.xml file to configure ForwardAction class as separate Action class.

Struts supplied <html: link> is alternate for the traditional <a> tag to prepare hyperlinks.

Example:-  <a href = “home.do”> tryagain </a>(or)

<html: link href = “home.do”> Tryagain </html: link>

<html: link action = “home.do”> Tryagain </html: link>

Here .do word is the extension word of ActionServlet url pattern (*.do)

Question: can we develop Struts application without form bean class (both manual & dynamic)?

Answer:    If Struts Action class is getting request from hyperlink of web page without data. Then form bean is not required.

  • If Struts Actoin class is getting request from form page and there is no need of perfering form validations, reset (-,-) method operations then the form bean can be mode as optional resource in the situation the execute method of StrutsAction class read the form data of form page through third parameter of execute () method i.e request object.

Different Types of Action Classes / Built in Action Classes

Different types of Action classes / Built in Action classes: –

  • SwitchAction
  • Forwordaction
  • Local Action
  • Include Action
  • Dispatch Action
  • Lookup Dispatch Action
  • Mapping Dispatch Action
  • Download Action
  • These classes are available in org.apache.Struts.Action package.
  • This package is available in Struts-home\lib\Stuts-extras-1.3.8.jar file.
  • Foll all these action classes the derect / indirect super class is org.apache.Struts.action.Action class.

 Different types of Action classes


<a href = “B.jsp”> go </a>

  • A.jsp is directly comm. with B.jsp. so we can say the diagram is violating MVC2 principle which says the two jsps of view layer must communicate each other through controller servlet.

Solution (1):-

Different types of Action classes Built in Action Classes


<a href = “xyz.do”> go </a>


    <action path = “/xyz” type = “xyzAction”>

         <forward name = “ok” path = “IB.jsp”/>


  • This diagram satisfies MVC2 principles towards hyperlink based communication b/w A.jsp and B.jsp that means A.jsp is communicating with B.jsp through the controller servlet called ActionServlet. But taking one separate Action class having only mapping.findForword () call in execute method to satisfy the requirement is meaningless and not recommended aperation.

Sulution (2):- (with forward action) 

  • In this diagram A.jsp is comm… With B.jsp through controller servlet. So we can say MVC2 principle is not violated more ever it is not taking support of any dummy action class to full fill the requirement.

With respect to diagram (1):-

1)      Enduser click on the go hyperlink of A.jsp

2)      Based on bref url the request url will be generated.

3)      ActionServlet traps & takes the request

4)      ActionServlet uses Struts-configuration file to get the TargetAction class

5)      ActionServlet finds forwardAction class as the Target Action class to execute based on the Acti action path “/xyz”

6)      The predefined execute (-,-) method of predefined forward Action class uses the parameter attribute value B.jsp and returns ActionForward object to ActionServlet pointing to B.jsp

7)      ActionServlet forwards the control to B.jsp

  • While working with all built-in Actionclasses including ForwordAction we must add Struts-home\lib\ Struts-extracts-1.3.8.jar file to WEB-INF\lib folder of your Struts application.
  • In MVC2 Arh. Based applications all the operations in the web application execution must take place under the control of controller servlet for better monitoring controller on the application execution.

Procedure to work with StrutsDemoApp1 application with programmiticDynamicFormBean

Procedure to work with StrutsDemoApp1 application with programmiticDynamicFormBean:

Step1:- Develop FormBean class as shown below manually


Package app;

Important org.apache.Struts.action.*;

Important org.apache.Struts.validator.*;

Important java.servlet.http.*;

Public class RegisterForm extends dynaValidatorForm


//no formbean properties

// no setxxx (-,-) & getxxx (-,-)

Public ActionErrors validate (-,-)


// call super.validate (-,-) to perform validation plug-in based form validations

ActionErrors errs = super.validate (mapping, req);

// read form data from form bean properties

String user = (String) get (“username”);

String pwd = (String) get (“password”);

// develop custom form validation logic (programatic)

// check whether user & pwd are having same length or not

If (errors.size () == 0)


Errors .add (“unpwderr”, new ActionMessage (“my.unpwd.len”))



S.o.pln (“size of error is” + errs.size ());

Return errs;

} // validate (-,-)


To compile this source file add commons-beanutil-1.7.0.jar file in class path as addition jar file.

Step2:- configure the above form bean class in struts configuration filr along with form properties.

In Struts-config.xml file:-



<form-bean name = “rf” type = “app.RegisterForm”>

< form-property name = “username” type = “java.long.String” initial = “ramu”/>

< form-property name = “password” type = “java.long.String” />



Step3:– write following code is RegisterAction.java to read form data from form bean class object.

Same as step(3) of working with declarative dynamic form bean [ref.previous scanerio] but write type casting stmt as show below.
Register fm = (RegisterForm) form;

Step4: – keep the remaining resource as it is.

  • Both DynaActionForm & DynaValidatorForm can generated FormBeans dynamically but DynaActionForm cannot work with validator plug-in where as DynaVakidatorForm can work with validator plug-in.
  • For complote example application that uses programaticDynamic bean and all the 3 appraoches to mixup our form validation logic with validator plug-in refer supplymentory handout given on 25/8/11
  • Example Application that uses maximum validator rules of validator plug-in along with dynamic FormBean utilization (Declarative):-
  • Nve- no form validation errors
  • Ve- validation Errors are there.
  • W.r.to above diagram (5)? indicates that ActionServlet perform validator plug-in based form validations on form bean data based on the entries placed in validation.xml and validator-rules.xml file.
  • For the above diagram based application refer application (4) of the booklet page no. 26-30.
  • When form page having multiple components then it is recommended to develop context in that form page as html table context to make to alignment form easily in the web page.

Question: why Application Parameter is removed from struts 1.3 to configure properties file?

Answer:    This application init parameter allows to configure only one property as a time. So it is recommends to use <message-resource> tag of <s-c>.xml file to configure multiple properties files….

  • Once java.sql.Data class object is given to jdbc driver it is a responsibility of jdbc driver to insert date value in the table column is the pattern i.e supported by underlying database software.

Converting string date value to java.sql.date class object when given date value pattern is yyyy-mm-dd.

String s = “2012-4-24”;

Java.sql.date sqdl = java.sql.date.valueOf (s);

  • Converting string date value to java.sql.date class object when given date value pattern is any pattern.

String s = “10-10-1983”;  // mm-dd-yyyy

//get java.util.date object

simpleDateFormat sdfl = new simple DateFormat (“mm-dd-yyyy”);

java.util.Date udl = sdfl.parse(s);

//get java.sql.Date object

Long ms = udl.get Time ()

Java.sql.Date sqd2 = new java.sql.Date (ms);