DispathAction example in Struts1

In this tutorial we will see how DispathAction in Struts work.

What is the need of DispathAction and when we will use this struts built-in action ?

  • When ever we want to implement a set of related functions into a single action class.
  • We don’t want to write separate action class for each function.

By using Struts built-in action we can achieve this i.e DispatchAction which is allows to write many methods/functions in to one Actio class which should be sub type oforg.apache.struts.actions.DispatchAction.

If you see in below example we have implemented one Action class i.e ManageBranchAction.java which extends DispatchAction,this action class have three functionalities like Create Branch,delete Branch, update Branch.

let us have a look in to below example.

Technologies used in this article :

1. Struts1.3
2. Maven 1.4
3. Eclipse 4.2
4. JDK 1.5

1. Create Maven Web project in Eclispe and add the Maven  dependencies like as as below Maven’s pom.xml file. 

 2. Implement the Form bean named “BranchForm” .

3. Implement the Action class  named “ManageBranchAction”.

4. Configure the Action Class and form bean in struts-config.xml like as below.

5. jsp file.

6 . Finally  Project Structure in Eclipse should like as below.


7. Configure the Tomcat server In eclipse , Deploy and run the Application.


Access the URL: http://localhost:8080/StrutsDispatchActionexample and enter the branchname and ifsc code and click on “create” button.

when we click on “create” button request will go to “ManageBranchAction” and “create” method will execute .


when we click on “delete” button, request will call same action class and delete method will execute.


Based on the parameter (method = create or delete or update ) respective method will execute in the same action class and will forward the request to view.


Download  Source Code

Posted in struts and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">