This discussion is archived
2 Replies Latest reply: Jan 21, 2013 1:19 PM by aksarben RSS

How to check checkbox values in servlet?

884510 Newbie
Currently Being Moderated
My web application has got a form with numerous items which includes check boxes too. I need to get the values of Checked check boxes alone from the jsp and use it for further manipulation in my servlet. But when i tried to check it i am getting null pointer exception.


i checked using the following coding methodology in my servlet:


String a = request.getParameter("CHECKBOX1'S NAME");
String b = request.getParameter("CHECKBOX2'S NAME");
.
.
.
.
String n = request.getParameter("CHECKBOXN'S NAME");

System.out.println(a+b+........+n);//to check whether null or on returned from jsp


if(a.equals(null) && b.equals(null) && ....n.equals(null)){// i am getting null pointer exception in the this line

/* Some logic here */
}else if ( a.equals("on") && b.equals("on") && ...n.equals("on")){

/* Some logic here */

}else if(a.equals("on") && b.equals("null").... n.equals("on")){
/* Some logic here */
}


likewise different combinations of else if's....{
/*
Some logic here
*/
}


thanks.

Edited by: 881507 on Jan 18, 2013 4:09 AM

Edited by: 881507 on Jan 18, 2013 4:11 AM

Edited by: 881507 on Jan 18, 2013 4:13 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points