| Author |
howto read a parameter from the URL (AS IS)
|
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
Hi, Consider the following URL: http://localhost:8080/MyApplc/activate.do?value=H+43bVonNVFCDe2lRSzOID== The idea is this: users receives this link (by email), they click the url and based on the 'value' the method does something. problem: the value on the URL is H+43bVonNVFCDe2lRSzOID== but the value of encrypted is H 43bVonNVFCDe2lRSzOID== * the + sign after the H was removed" So...how can I read the 'value' as is? thank you!
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
If the parameter value was really supposed to be "H+43b..." and so on, then you should URL-encode that value before appending it to the URL. As it is, the servlet container is assuming that it was URL-encoded (as per the rules for URLs) and is URL-decoding it. This translates + to space, among other things.
|
 |
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
almost... the link was: http://localhost:8080/MyApplc/activate.do?value=H+43bVonNVFCDe2lRSzOID== the encrypted filed is H+43bVonNVFCDe2lRSzOID%3D%3D '=' becomes 3D% mmm....
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
That value looks more like Base64 encoded, not URL encoded.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
that's correct, I have this line in my code that produces this: cipherText = new BASE64Encoder().encode(byteCipherText); how can I get around this? thanks
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
What I would do: When generating the URL, base64 it first, then URLencode. The + (part of the base64) will be replaced with %2B. Then when you want to read it again, URLdecode it again (if the server doesn't do that for you), then de-base64 it.
|
 |
 |
|
|
subject: howto read a parameter from the URL (AS IS)
|
|
|