1

i have to pass a array of values to a jsp page. i am using the following jquery function

$.post("add.jsp" ,{'URL_Arr': urlarray}, function (data) {   
    alert(urlarray);
    $('#einfo').html(data);
});

where, urlarray is an array.Alert shows me the (urlarray)array values as 48,39,28

And add.jsp page conatains the following

String URL_Arr1=request.getParameter("URL_Arr");
out.println("arr:"+URL_Arr1);

Am getting the URL_Arr as null

Can any one help me in passing the array values to another jsp page using jquery post.

2
  • Remove quotes around URL_Arr in that code: {'URL_Arr': urlarray} Commented Apr 22, 2011 at 9:52
  • @CoolEsh: those quotes are valid. Commented Apr 22, 2011 at 12:44

1 Answer 1

5

For arrays, jQuery will suffix the parameter name with [], so use URL_Arr[] as parameter name. You should also be using getParameterValues() to get all array values. The getParameter() would only return the first item.

Summarized:

String[] urlarray = request.getParameterValues("URL_Arr[]");
// ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.