Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get multiple parameter values with same Name?

843840Mar 3 2008 — edited Mar 4 2008
Hi,

I am having a jsp which has multiple check boxes with the same Name. I am trying to figure out which check boxes are checked.
<%int iVal = 2;
while(it.hasNext()){
		String key = (String)it.next();	%>

		<tr>
			<td>
				<label><%=(String)map.get(key)%></label>
			</td>
			<td>
				<input type="checkbox" name="delCheckBox" value=""con" + <%=iVal%>">
			</td>
		</tr>
	<%iVal++; }%>
This is what I am trying to do to get the values:
String [] cb = request.getServletRequest().getParameterValues("delCheckBox");
if(cb == null)	cb = new String[]{};

if(cb!=null) {
	for (int i = 0; i < cb.length; i++) {
		response.write(cb);
response.write(" ");
}
}
When I check 4 check boxes in the html page, I am able to get the cb.length = 4.
But how do I get the contents of this string array?

Thanks,
Rishi                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2008
Added on Mar 3 2008
5 comments
263 views