Struts2.2.1 checkbox tag example.
Posted on: January 10, 2011 at 12:00 AM
In this tutorial, you will see the example of Struts2.2.1 checkbox tag.

Struts2.2.1 checkbox tag example.

In this example, you will see the use of checkbox tag of struts2.2.1 framework. The checkbox tag is a UI tag that is used to render an HTML input element of type checkbox, populated by the specified property from the ValueStack. 

Directory structure of checkbox tag example.

 1- index.jsp  

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




<h2>Struts2.2.1_ChexkBox_Tag_Example</h2><hr />

<h2>Select value of check box</h2>

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

<s:checkbox name="hello" label="Hello" value="true"> </s:checkbox>

<s:checkbox name="hi" label="Hi"> </s:checkbox>

<s:checkbox name="gm" label="GoodMorning"> </s:checkbox>

<s:submit name="submit" value="Submit" />



2-CheckBoxAction .java

package roseindia;

import com.opensymphony.xwork2.ActionSupport;

public class CheckBoxAction extends ActionSupport{

private boolean hello;

private boolean hi;

private boolean gm;

public String execute() throws Exception {

return SUCCESS;


public boolean isHello() {

return hello;


public void setHello(boolean hello) {

this.hello = hello;


public boolean isHi() {

return hi;


public void setHi(boolean hi) {

this.hi = hi;


public boolean isGm() {

return gm;


public void setGm(boolean gm) { = gm;





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

<action name="checkbox" class="roseindia.CheckBoxAction">

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





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



<style type="text/css">

p {color: gray;}</style>




<h2>value of check box</h2><p>

Hello : <s:property value="hello"/><br/>

Hi : <s:property value="hi"/><br/>

GoodMorning : <s:property value="gm"/><br/></p>







Download Select Source Code

Related Tags for Struts2.2.1 checkbox tag example.:




Advertisement null