I have below the url.
http://localhost:8080/servlet?user=John&message=hai&hello&recipient=scott
In above url i have 3 request parameters as below.
user=John
message=hai&hello
recipient=scott
Here the problem is with message
request parameter's value.because here its value contains ampersend (&). when i try request.getParameter("message")
then i get only hai
but not hai&hello
. How can i solve this issue?
Thanks!
If you are sure that
&recipient
always comes after&message
or that&message
may come as last parameter or you know the set of possible parameters, then you will need the get the query string from the request and try to split it accordingly.For example if
&recipient
alway comes after&message
then you could do (pseudo code / untested):Try this, instead
....&message=hi%26hello....
. I mean, encode it.[Edited]
As you said you have no control over it, and it is legacy application and they cannot fix it; then you can still, I suppose, use
URLEncoder
to encode the URL.[Edited]
..or just treat it as a
String
. Simple, isn't it?