jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Retriving values from  html:checkbox  in a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Retriving values from  html:checkbox  in a jsp" Watch "Retriving values from  html:checkbox  in a jsp" New topic

Retriving values from html:checkbox in a jsp

skumar mk

Joined: Jul 02, 2008
Posts: 12
Hai All,

Am facing a problem to retrive the values from the <html:chechbox>
Am using code like this:

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:form action="/log" method ="post">
<table width="500" border="0">
<td>username :</td>
<td><html:text property="username" /></td>
<td>password : <br><br></td>
<td><html assword property="password" /><br><br></td>
<td><html:submit property="login" value="ADD"></td>
<logic resent name="LIST_ELEMENTS" scope="request">

<logic:iterate id="myvalues" name="LIST_ELEMENTS">

<html:checkbox property="ck_values" >

<bean:write name="myvalues" />


</logic resent>



In the action class am setting the values ArrayList and storing it in the request scope

java.util.ArrayList list = new java.util.ArrayList();

I need the values selected from the checkbox (vmarks,vid). when am using request.getString("ck_values") am getting ON then how can i retrive the slected values in my action class.

Please help me out.

Thanks in advance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Use html:multibox instead of html:checkbox. It still produces checkboxes, but is designed to be used with a group of related checkboxes all with the same property name. Below is the link to do documentation.


Consultant, Sima Solutions
I agree. Here's the link: http://aspose.com/file-tools
subject: Retriving values from html:checkbox in a jsp
It's not a secret anymore!