
html: checkbox Tag - is used to create a Checkbox Input Field.
This tag creates an HTML <input> element of type checkbox, populated from the specified value or the specified property of the bean associated with our current form.
NOTE :
| Name | Description |
| disabled | Set to true if this input field should be disabled. |
| name | The attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. |
| property | Name of the request parameter that will be included with this submission, set to the specified value. |
| value | The value to be transmitted if this checkbox is checked when the form is submitted. If not specified, the value "on" will be returned. |
Example Illustrating the use of the Radio<html:checkbox
> tag :
Here you will learn to use the Struts Html <html:checkbox
> tag.
We will cover an example that will show a working of<html:checkbox
> tag.
Example code :
Creating an Action Class :
Develop a simple action class CheckBoxTagAction.java.
|
package ActionForm;
|
<form-bean name="CheckBoxTagActionForm"
|
<action input="/" name="CheckBoxTagActionForm" path="/CheckBoxTagAction"
|
Developing the HtmlCheckBoxTag.jsp page :
|
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body bgcolor="#999933"> <h3><font color="#FFFF33"> select CheackBox For Demonstration......... </font> </h3> <table border="2"> <tr> <th align="right"><font color="#FFFF33">CheckBoxTag Demo: </font> </th> <html:form action="CheckBoxTagAction" method="POST"> <td align="left">select <html:checkbox name="CheckBoxTagActionForm" property="select" /> </td> <td align="left"> <html:submit/> </td> </html:form> </tr> </table> </body> </html> |
Developing the HtmlCheckBoxTagOutPut.jsp page :
|
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><font color="#FFFF33">OUT PUT</font></title> </head> <body bgcolor="#999933"> <h3><font color="#FFFF33">OUT PUT</font></h3> <h3><font color="#FFFF33">Selected Value is.......</font></h3> <bean:write name="CheckBoxTagActionForm" property="select"/> </body> </html> |
Add the following line in the index.jsp to call the form :
| <a href="HtmlCheckBoxTag.jsp">HtmlCheckBoxTagDemo</a><br/> |
Building and Testing the Example :
Build and deploy and Test the application .
Open the browser and navigate to the HtmlCheckBoxTag.jsp page.
Your browser displays the following page.
Don't select checkbox on the HtmlCheckBoxTag.jsp page, and
see the output.
![]() |
Output:
![]() |
Now select the checkbox on the HtmlCheckBoxTag.jsp, and see the output.
![]() |
Output:
![]() |
Above demo Displays the working of<html:checkbox>tag.

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Checkbox Tag:
View All Comments
Post your Comment