Struts2.2.1 Append Tag Example
Posted on: January 3, 2011 at 12:00 AM
Struts 2.2.1 Append tag is used to Append an iterator based on the ?id? attribute provided in the page.

Struts2.2.1 Append Tag Example

Struts 2.2.1 Append tag is used to Append an iterator based on the ?id? attribute provided in the page.Struts2.2.1 append tag is used to combine few Iterators (created by List or Map) into a single Iterator. Append Iterator Tag is used to append iterators to form an appended iterator 
through which the entries goes from one iterator to another after each respective iterator is exhausted of entries.

The following Example will shows how to implement the Append tag in the Struts2.2.1 --

First we create a JSP file named Append.jsp as follows.

<%@ page language="java" contentType="text/html; charset=UTF-8"


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

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



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Append Tag Example</title>



<h1>Struts 2 Append tag example</h1>

Combine ArrayList1 and ArrayList2 into a single iterator.

<s:append id="AppendList">

<s:param value="%{list1}" />

<s:param value="%{list2}" />


<s:iterator value="%{#AppendList}">

<li><s:property /></li>




The index.jsp file is as follows- This file only contains the hiperlink only.


<a href="AppendTag.action">Append Control Tag Example</a>


The Struts mapping file Struts.xml is as follows-


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

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

<constant name="struts.custom.i18n.resources" value="ApplicationResources" />

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

<action name="AppendTag" class="Roseindia.AppendTag">

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




The action class is as follows.

package Roseindia;

import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
import org.apache.struts2.util.AppendIteratorFilter;

public class AppendTag extends ActionSupport {

private List<String> list1 = new ArrayList<String>();
private List<String> list2 = new ArrayList<String>();

public String execute() throws Exception {



return SUCCESS;
public List<String> getList1() {
return list1;
public List<String> getList2() {
return list2;

This Program produces output on the basis of the Append tag evaluation, This  give the output as-


Download Select Source Code

Related Tags for Struts2.2.1 Append Tag Example:



Advertisement null