aspose file tools*
The moose likes Java in General and the fly likes howto read a parameter from the URL  (AS IS) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "howto read a parameter from the URL  (AS IS)" Watch "howto read a parameter from the URL  (AS IS)" New topic
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: 18901
    
    8

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: 19760
    
  20

That value looks more like Base64 encoded, not URL encoded.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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: 19760
    
  20

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: howto read a parameter from the URL (AS IS)