Hidden Tag Example Struts2

Problem while setting a variable value in the hidden field?

Solution: 

Here is the complete example of hidden filed, we will see how to pass a value of a variable in value attribute of the hidden filed.

the below example is in the flow of the program control through the files.

---index.jsp---
<%@taglib uri="/struts-tags" prefix="s"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

hidden filed example
click
    
---struts.xml---
welcome.jsp
final.jsp

—One.java—

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package abhi;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;

public class One extends  ActionSupport{
    int a;
    Map session;
    @Override
    public String execute()
    {
     int a=10;
     session = ActionContext.getContext().getSession();
        session.put("a1",a);
     System.out.println(session);
        return "success";
    }
}

—welcome.jsp—

<%@taglib prefix="s" uri="/struts-tags"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

---Two.java---
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package abhi;

import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;

public class Two extends ActionSupport{
    ArrayList abc=new ArrayList();
    int xyz;

    public ArrayList getAbc() {
        return abc;
    }

    public void setAbc(ArrayList abc) {
        this.abc = abc;
    }

    public int getXyz() {
        return xyz;
    }

    public void setXyz(int xyz) {
        this.xyz = xyz;
    }

    @Override

    public String execute()
    {
     System.out.println(abc);
     System.out.println(xyz);
        return "success";
    }
}

—final.jsp—

<%@page contentType="text/html" pageEncoding="UTF-8"%>

you got your value successfully