1

Hello i have an url in my jsp and i want to pass an array of string in this url to recover in my ActionForm

6
  • 1
    So, do you have Java array or JavaScript array? Commented Oct 18, 2010 at 13:27
  • i have a seven checkbox and when i click in my url i want to pass what box is checked Commented Oct 18, 2010 at 13:29
  • serialization Or json encode ! Commented Oct 18, 2010 at 13:30
  • would you have a simple example Commented Oct 18, 2010 at 13:31
  • code.google.com/p/json-simple/wiki/… am not a java guy . but am using json encode in php . but this example is for java. If these are tough for you concatinate those array parameters and make it a string and pass. :) Commented Oct 18, 2010 at 13:49

3 Answers 3

4

If you are dealing with something simple like a list of numeric ids, i would just run through the check boxes, create a comma separated list, and assign it to a query string parameter. On the other side i would split the string. If the values are more complex you have to consider escape characters. Also if you are dealing with a long list, the url is not the best way to pass this data.

Sign up to request clarification or add additional context in comments.

Comments

3

You can use 'standard' html way of passing arrays of data: http://mywebsite/mypage?myarray=value1&myarray=value2&myarray=value3. Then you can fetch all values of parameter myarray from request object (if framework doesn't provide more elegant ways of handling arrays).

But seeing your comment, I would recommend to leave JavaScript and just declare a form for it.
If you need a link (not button), you can always submit form from it. Something like <a href="javascript:$('#myForm').submit();">...</a>

Comments

0

Try Json encode

http://code.google.com/p/json-simple/

Check this

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.