aspose file tools*
The moose likes JSP and the fly likes Check Box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Check Box " Watch "Check Box " New topic
Author

Check Box

Ashok Kulkarni
Greenhorn

Joined: Nov 18, 2003
Posts: 4
Hi i have n number of check boxes in jsp, i have assigned ids for each checkbox
i want kown which one is selected and catch the values of checked ones
in servlet.can any one give soln for this..plsss
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 639
Ashok,
I m not sure abt the use of id,but I have following option for your problem....
<input type="checkbox" name="chk1" value="1">
<input type="checkbox" name="chk1" value="2">
<input type="checkbox" name="chk1" value="3">
make sure names for all checkbox are same
And you can use request.getParameterValues() to chekc whihc one is selected as below
String s[]=request.getParameterValues("chk1");//chk1 is the name of chkbox
for(int i=0;i<s.length;++i)
out.println(s[i]);
Hope this helps
Cheers
Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Ashok Kulkarni
Greenhorn

Joined: Nov 18, 2003
Posts: 4
thanx ,,,,
But i am getting Null pointer Exception
where i need to pass check box name through url ...
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 639
you just need to put all check box and submit button in same form tag
<form>
<input type=...
...
..
<input type=submit value="hit me">
</form>
are you using any link for submitting your form ??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Check Box