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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 16483
    
    2

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: howto read a parameter from the URL (AS IS)
 
Similar Threads
Obtain Get Parameters using HttpServletRequest
how to send an attribute to servlet via form action?
A 404 Error, need help configuring web.xml
Servlets with Tomcat 4
Route requests by address