I have an HTML form that calls a Java servlet and the form contains 20 checkboxes (e.g. with names of c1, c2, c3...c20).
I'm trying to capture the value of those checkboxes in a java boolean array cbox.
The following code...
int ii=0;
boolean cbox[] = new boolean[20];
for (ii=0; ii<20; ii++)
cbox[ii] = (req.getParameter("c"+String.valueOf((int)(ii+1))).equals("on"))?true:false;
gives a java.lang.NullPointerException.
But, I don't get a run time error if I were to change it to (e.g. remove ii in valueOf):
cbox[ii] = (req.getParameter("c"+String.valueOf((int)(1))).equals("on"))?true:false;
Of course, that doesn't get me where I want. I must be making a silly mistake somewhere but I can't spot it. Does anyone see it?