boyyle
asked on
request.getParameterValues()---how?
i have this code in my jsp page:
<%
String myArray[] = request.getParameterValues ("myTextBo x");
int myLength = java.lang.reflect.Array.ge tLength(my Array);
%>
so,my concern is, if myArray[] not empty,the java.lang.reflect.Array.ge tLength is working.
but if myArray[] is empty, i get the error message....
so, may i know is there any function to check whether the myArray[] is empty or not???
thanx
<%
String myArray[] = request.getParameterValues
int myLength = java.lang.reflect.Array.ge
%>
so,my concern is, if myArray[] not empty,the java.lang.reflect.Array.ge
but if myArray[] is empty, i get the error message....
so, may i know is there any function to check whether the myArray[] is empty or not???
thanx
Check if it is null.
To check the length of array, you can use
myArray.length
This will return 0 if the myArray empty.int myLength = (myArray == null ? 0 : myArray.length);
myArray.length
This will return 0 if the myArray empty.int myLength = (myArray == null ? 0 : myArray.length);
myArray.length
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I believe Array.length(array) returns the same thing as array.length.
SO I'd say the problem is that you need to check if null as yongsing originally stated.
SO I'd say the problem is that you need to check if null as yongsing originally stated.