|
 |
pro_jsp thread: help: compareTo(checkbox,"")==0 , not work
Message #1 by ngngachuen@i... on Wed, 21 Feb 2001 10:33:33
|
|
Hi,
I am not sure what you are trying to do, but I have some ideas for you. If
a checkbox on the client is not checked on the client(web browser) it does
not send a value or even its name to the server. If I have a lot of
checkboxes that are related to the same thing, I like to give them the same
name. That sends all of their values in a list to the server. You can use
request.getParamterValues to get the values. Here is an example:
if (request.getParameterValues("myCheckBox") != null)
{
String [] CheckboxVal = request.getParameterValues("myCheckBox");
for (int i = 0; i < CheckboxVal.length; i++)
{
out.println("I saw ["+ CheckboxVal[i] + "]");
}
}
I hope that helps.
Tosh
-----Original Message-----
From: ngngachuen@i... [mailto:ngngachuen@i...]
Sent: Wednesday, February 21, 2001 5:34 AM
To: Pro_JavaServer_Pages
Subject: [pro_jsp] help: compareTo(checkbox,"")==0 , not work
hi...
i tried to check the checkbox whether it is checked or not by using the
following code:
-------code-----------
int count= Integer.parseInt(request.getParameter("count"));
String[] icheck =new String[count];
int store =0;
for(i=0;i<count;i++){
String checkbox= "checkbox"+i;
String temp= request.getParameter(checkbox);
if(temp.compareTo("")==0){
System.out.println(i+" is null \n");
}
else {
icheck[store]=temp;
store++;
}
}
-----------------------------------
but when i run it .
the following error comes out :
javax.servelet.ServletException , ,,,
java.lang.NullPointerException..
pls help me
thx
ngachuen
|
|
 |