Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping & in a URL

Tags:

java

url

uri

jsp

I am using jsps and in my url I have a value for a variable like say "L & T". Now when I try to retrieve the value for it by using request.getParameter I get only "L". It recognizes "&" as a separator and thus it is not getting considered as a whole string.

How do I solve this problem?

like image 612
user265950 Avatar asked Feb 04 '10 07:02

user265950


People also ask

What is the synonyms of the escaping?

Some common synonyms of escape are avoid, elude, eschew, evade, and shun. While all these words mean "to get away or keep away from something," escape stresses the fact of getting away or being passed by not necessarily through effort or by conscious intent.

What is the meaning of escaping reality?

a defensive reaction involving the use of fantasy as a means of avoiding conflicts and problems of daily living. See also flight from reality.

What is the meaning of escaping in time?

If certain animals are unable to migrate, they respond to unfavourable abiotic stress by "escaping in time". This means that instead of migrating to some other place , they avoid unfavourable conditions by staying in the same place but by hiding or sleeping .

What is a person who escaped called?

Definition of escapee : one that has escaped especially : an escaped prisoner.


2 Answers

java.net.URLEncoder.encode("L & T", "utf8")

this outputs the URL-encoded, which is fine as a GET parameter:

L+%26+T
like image 81
Bozho Avatar answered Sep 21 '22 06:09

Bozho


A literal ampersand in a URL should be encoded as: %26

// Your URL
http://www.example.com?a=l&t

// Encoded
http://www.example.com?a=l%26t
like image 20
Erik Avatar answered Sep 23 '22 06:09

Erik