Struts2.2.1 UI tag example.
Posted on: January 17, 2011 at 12:00 AM
In this section, you will see the use of struts UI tag.

Struts2.2.1 UI tag example.

In this tutorial, you will see the use of some UI_ tags of struts framework.

 1- index.jsp




<a href="uiTagAction.action">Example of UI Tags.</a>



2_ uiTags.jsp

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



<style type="text/css"> .bh{width: 146;height: 40;}</style></head>


<s:form action="Information.action">

<s:label name="formName" value="Student Registration Form........"/>

<s:textfield name="name" label="Name"></s:textfield>

<s:textarea name="address" label="Address" cssClass="bh"></s:textarea>

<s:password label="Password" name="password"></s:password>

<s:radio list="{'Male','Female'}" name="gender" label="Gender" ></s:radio>

<s:select list="course" name="courseName" headerKey="0"

 headerValue="Select Course" label="Course Name"></s:select>

<s:hidden name="message" value="Hello friends....." ></s:hidden>

<s:reset></s:reset> <br><s:submit></s:submit>





package roseindia.action;

import java.util.ArrayList;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class UITagAction extends ActionSupport {

private List<String> course;

private String courseName;

private String name;

private String address;

private String password;

private String gender;

private String message;

public String getName() {

return name;

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


public String getAddress() {

return address;


public void setAddress(String address) {

this.address = address;


public String getPassword() {

return password;


public void setPassword(String password) {

this.password = password;


public String getGender() {

return gender;


public void setGender(String gender) {

this.gender = gender;


public String getMessage() {

return message;


public void setMessage(String message) {

this.message = message;


public String getCourseName() {

return courseName;


public void setCourseName(String courseName) {

this.courseName = courseName;


public List<String> getCourse() {

return course;


public void setCourse(List<String> course) {

this.course = course;


public UITagAction() {

course = new ArrayList<String>();







public String execute() throws Exception {

return SUCCESS; }


4_ struts.xml


<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<constant name="struts.devMode" value="false" />

<package name="bharat" extends="struts-default" namespace="/">

<action name="uiTagAction" class="roseindia.action.UITagAction">

<result >/uitags.jsp</result>


<action name="Information" class="roseindia.action.UITagAction">

<result name="success" >/outputPage.jsp</result>




5_ outputPage.jsp

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




<h4>Student information</h4>

Student Name : <s:property value="name"/><br/>

Student Address : <s:property value="address"/><br/>

Student Password : <s:property value="password"/><br/>

Student Gender : <s:property value="gender"/><br/>

Student Course : <s:property value="courseName"/><br/>

Hidden Message :<s:property value="message"/>







Download Select Source Code

Related Tags for Struts2.2.1 UI tag example.: