Link to home
Start Free TrialLog in
Avatar of ram_os
ram_os

asked on

passing a variable in the address bar

How can I pass the variable name to the next page through the address bar? The way ive been trying will not pass anything after the blank space between the firstname and lastname

name = "adro ron";
out.print("<form name='Form1231' method='post' action="+request.getContextPath()+"/allocate_actualtime.jsp?customername="+firstnames[cnt]+lastnames[cnt]+"&names="+name+">");
Thanks
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland 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
Avatar of ram_os
ram_os

ASKER

Thanks Tim, that worked....

Could you explain your code plz and why I needed to do it, if you dont mind,
Thanks again
Yeah, sure :-)

You basically, can't have any special characters, spaces, "?"s, or "&"s in your parameters, as the browser will think they are gaps in the url, or the start of a parameter list or the next parameter, etc

So...

You have to encode the parameters so that they get read correctly by the browser

The way to encode things is like this:

%XX

where XX is the ascii value of the special character

So " " becomes "%20"

and URLEncoder.encode does this for you :-)

Hope you understand :-)

Glad I could help :-)

Tim