I'm trying to retrieve the value of a radio button in a servlet but im getting ON for the ones i have selected and Null for the ones i have not selected. I'm not getting the values. Please do help me out.
The Servlet
for(int i=0;i<itemnode.getLength();i++){
ans[i] = request.getParameter(Integer.toString(i));
System.out.println(ans[i]);
}
The html page :
<input type="radio" name="1" value="1" style="float: left;">
<input type="radio" name="1" value="2" style="float: left;">
<input type="radio" name="1" value="3" style="float: left;">
<input type="radio" name="1" value="4" style="float: left;">
<input type="radio" name="2" value="1" style="float: left;">
<input type="radio" name="2" value="2" style="float: left;">
<input type="radio" name="2" value="3" style="float: left;">
<input type="radio" name="2" value="4" style="float: left;">
The output at console:
null
on
Null for the ones i have not selected and On for the ones i have selected