0

hi helpers,
i'm trying to read an array from jsp in to java(servlet) page
the code is
JSP CODE (readingcheck box values):

String select[] = request.getParameterValues("sel"); 

if (select != null && select.length != 0) {

for (int i = 0; i < select.length; i++) {
out.println(select[i]);

its working ok!

JAVA CODE(reading array values):

String select2[] = request.getParameterValues("select"); 
for (int i = 0; i < select2.length; i++) 
{
System.out.println(select2[i]);
}

the above java code didnt worked.

i also tried this

String[] select= new String[100];
for (int i = 0; i <10 ; i++)
{
select[i] = request.getParameter(select[i]);
System.out.println(select[i]);
}

this didnt worked too
is there any other way to read array values from jsp page?
where am i wrong?

thanks,
BeanBoy !

2
Contributors
3
Replies
5
Views
8 Years
Discussion Span
Last Post by Thirusha
0

getParameter only works if the parameter you are accessing exists in the URL that was sent to the servlet.

Are you sure that the array is being sent to the servlet?

If the url is this : "/jspservlet?name=blah&myArray={1,2,3}" (the curly brackets would be replaced with the correct url encode for brackets which would be %something), then using request.getParameter("myArray") would return the array.

0

getParameter only works if the parameter you are accessing exi..........."myArray") would return the array.

its working ! thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.