0

I get list on my jsp using

 <%List selectedArray = (List) session.getAttribute("clist");%>

is [4,5].And I am sending this list to javascript using hidden variable in jsp

 <input type='hidden' id="agencycontactid" name="agencycontactid" value="<%=selectedArray%>" />

and i am taking this in javascript var abc=$('#agencycontactid').val(); . I want to send this abc to servlet using ajax call that is through data.And i want this list in simple array format in servlet. Please help me.

Thanks

1 Answer 1

1

If you wanna pass an actual array (ie. an indexed array) then you can do:

 $.post('/url', {'someKeyName': ['value','value']});

You can also build a param string by looping other the data (in my case a multi-select)

$(".choosenItems option").each(function() {
        chosenStr = chosenStr + "&chItems=" + $(this).val();
});

so if you create a queryString of

   ...?name=Fred&name=Joe&name=Sally

then in your servlet you can do

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

4 Comments

so in that case the second option is suitable.
i didn't get ur answer.
Does this answer you question?
That would make no functional difference. If this question helped you please consider accepting this answer and/or upvoting it.

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.