Struts 2 Push Tag Example

 Download this Project

In this article, we will learn how to use a push tag in struts2. Below is the syntax for the push tag.

<s:push value="someObject">
       <s:property value="obejctProperty" />

1. Development Environment 

  1. Eclipse
  2. JDK 1.8
  3. Tomcat 8.5
  4. Maven

2. Create a Maven Web Project

Below is my dynamic web project struts2-push-tag structure in eclipse. In this example, we are using struts 2.1.8 version.

This project has the following actions,

  • push-tag.action: In this action, we will see the values of the User object defined in Action class.


package com.simba.demo;

import com.opensymphony.xwork2.ActionSupport;

 * @author Simba
public class PushTagExampleAction extends ActionSupport {

  private User user;

  public PushTagExampleAction() {
  public String pushTagExample() {
    user=new User();
    user.setDescription("Daenerys of the House Targaryen, the First of Her Name, Breaker of Chains and Mother of Dragons.");
    return SUCCESS;

  public User getUser() {
    return user;

  public void setUser(User user) {
    this.user = user;

package com.simba.demo;

 * @author Simba
public class User {

  private String name;
  private String gender;
  private String description;
  private Integer age;

  public String getName() {
    return name;
  public void setName(String name) { = name;
  public String getGender() {
    return gender;
  public void setGender(String gender) {
    this.gender = gender;
  public String getDescription() {
    return description;
  public void setDescription(String description) {
    this.description = description;
  public Integer getAge() {
    return age;
  public void setAge(Integer age) {
    this.age = age;

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Push Tag Example</title>
  <h1>Push Tag Example</h1>
  <s:push value="user">
        <td>Name :</td>
        <td><s:property value="name" /></td>
        <td>Gender :</td>
        <td><s:property value="gender" /></td>
        <td>Description :</td>
        <td><s:property value="description" /></td>
        <td>Age :</td>
        <td><s:property value="age" /></td>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


  <package name="pushTag" namespace="/" extends="struts-default">
    <action name="push-tag" class="com.simba.demo.PushTagExampleAction" method="pushTagExample">

 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "" >

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

3. Testing

In your eclipse configure tomcat and run your application by selecting Run on server.