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 !

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.

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

its working ! thanks

Pleasure, glad to help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.