Thursday, July 1, 2010

Struts2 Data control Bean Tag Example

Struts2 Bean Tag Example

Aim:
            Bean tag is used to instantiates the bean class and set the value and gets the value.

Procedure:

            Step 1:

                        Create Project name as BeanPro

            Step 2:

                        Create Action class name as BeanTag

package example;

import java.io.Serializable;

public class BeanTag implements Serializable
{
    private String name;

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

}

Step 3:

            Create success.jsp



< %@taglib uri="/struts-tags" prefix="s" % >
< html >
< head >

< title > JSP Page < /title >
< /head >
< body >
< s:bean name="example.BeanTag" id="uid" >
< s:param name="name" > SureshKumar < /s:param >
< s:property value="%{name}"/ >
< /s:bean >
< /body >
< /html >

step 5:

            Run the success.jsp

Directory structure of this project


No comments:

Post a Comment