Link to home
Start Free TrialLog in
Avatar of pmac38CDS
pmac38CDS

asked on

Pass multiple variables in a query string

I want to pass multiple variables in a query string. However is there anyway to pass them to avoid the url being very long ?
Avatar of enachemc
enachemc
Flag of Afghanistan image

use POST for sending the parameters. The URL will only be formed by the site name and page name
Avatar of pmac38CDS
pmac38CDS

ASKER

Using POST is not an option in my case.
You can pass multiple parameters as follows:
<a href="yourpage.htm?code=XYZ&moreinfo=test%20description">Test link</a><br />


you can refer to this article on passing parameters and using javascript to retreive the parameters
http://javascript.about.com/library/blqs.htm
I guess that you could write some JS to make the parameters string, zip it, encode it and send the result as a value for a single new param
you would have to decode it on the server side
but this is a workaround
Avatar of Sathish David  Kumar N
If yous Jsp then use hidden filed set the passing values in the hidden filed take it in java using request.getParameter()
<form onsubmit="concatenate();return false">
<input id="a" />
<input id="b" />
<input id="c" />
<input id="d" />
<input type="submit" value="submit" />
</form>

Open in new window


with :

function concatenate()  {
   var a = document.getElementById("a").value;
   var b = document.getElementById("b").value;
   var c =  document.getElementById("c").value;
   var d = document.getElementById("d").value;
   location.href = "/path/to/page?AllInOne=" + encodeURIComponent( a + ";" + b + ";" + c + ";" + d ); // semicolon is a reserved char, you can choose an other one
}

Open in new window

leakim971:How can I read the concatenated values in the aspx page ?
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the points!