||Struts 1.x 2.x | Spring | Strips | Wicket | Tapestry | Seam | JSF | RIFE | DWR | DOJO | EXT | Jquery | Json | Prototype | Hibernate | iBatis | web 2.0 | www.siva2baba.com & shivababa@gmail.com
  FrameWorks Theater
  Struts 1.X & 2.x


   -->Struts 1.x Life Cycle
           --> Action Types
   --->Struts 2.x Life Cycle
   --->Different between Struts 1.x Struts 2.x
   --->Developer Point of View Struts 1.x and Struts 2.x
   --->Step by step Develpement:
Struts 1.X -Example
   --->Step by step Develpement: Struts 2.X -Example
Example program --http://siva2baba.diinoweb.com

Struts 1.x life Cycle

           client  HTTP Request
               Action-servlet (web.xml)
                      Request Processor(process())
                               Action class(execute())
                                       Return Action Forward(struts.comfig.xml)
                             HTTP Response() to client
Action Types:
1.Forward Action
2.Dispatch Action
3.include Action
4.lookUpDispatch Action:
5.MappingDispatch Action
6.switch Action
7.Locale Action

Dispatch Action:
It provides mechanism to  collect related functions into a single action and eliminates the need of creating multiple independent actions for each function.
Forward Action:
It enables to forward request to the specified URL.
Include Action:
It  provides mechanism to include the contents of a specified URL.
LookUpDispatch Action:
It  provides mechanism  to combine many similar actions into a single action class, in order to simplify the  application design .Java map class is used to dispatch methods.
MappingDispatch Action:
It lets you combine many related actions into a single action class and manage through  creating multiple action-mappings.
switch Action:
It provides a mechanism to switch between modules and  then forwards control to a URI (specified in a number of possible ways) within the new module.
Locale Action:
It  provides mechanism to set a user's locale and further forwarding that to a specified page.

Struts 1.x  + WebWork Framework = Struts 2

Struts 2.x Life Cycle

       web browser requests

                Filter Dispatcher

               Interceptors(to perform workflow, validation,
                                            and file upload handling)

                Action(The Action method executes, usually storing and/or
                              retrieving information from a database)

                The Result renders the output to the browser, be it
                 HTML, images, PDF, or something else
Struts 1 Struts 2
Action Action
ActionForm Action POJO
ActionForward Result
Struts-config.xml struts.xml
RequestProcess Interceptors
ActionServlet FilterDispatcher
validation.xml Action-validation.xml

Step by step Develpement:
Struts 1.X -Example

    Struts 1.x Example


Step by step Develpement:
Struts 2.X -Example

Struts 2.X -Example




<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Struts Helloworld</display-name>






        <META HTTP-EQUIV="Refresh" CONTENT="0;URL=pages/HelloTime.action">
        <p>Loading ...</p>


<?xml version="1.0" encoding="UTF-8" ?>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <package name="mypackage" namespace="/pages" extends="struts-default">
        <action name="HelloTime" class="mypackage.HelloTime">
        <action name="*" class="mypackage.HelloTime">
        <!-- Add actions here -->


 * HelloTime.java
* Created on Jan 18, 2008, 3:22:49 PM
 * To change this template, choose Tools | Templates
 * and open the template in the editor.

package mypackage;

 * @author 150883
import com.opensymphony.xwork2.ActionSupport;
import java.util.Date;

public class HelloTime extends ActionSupport {
    public static final String MESSAGE = "My Own Struts 2 Hello Time Tutorial!";
    public String execute() throws Exception {
        return SUCCESS;
    private String message;
    public void setMessage(String message){
        this.message = message;
    public String getMessage() {
        return message;
    public String getCurrentTime(){
        return new Date().toString();


<%@ taglib prefix="s" uri="/struts-tags" %>
        <title>Struts 2 Hello Time Application!</title>
        <h2><s:property value="message" /></h2>
        <p>Current date and time is: <b><s:property value="currentTime" /></b>

  Today, there have been 2 visitors (14 hits) on this page! www.siva2baba.com & shivababa@gmail.com  
=> Do you also want a homepage for free? Then click here! <=
||Struts 1.x 2.x | Spring | Strips | Wicket | Tapestry | Seam | JSF | RIFE | DWR | DOJO | EXT | Jquery | Json | Prototype | Hibernate | iBatis | web 2.0 | http://siva2baba.diinoweb.com/files/ and www.siva2baba.com