0

I have code where an url is decoded in php. Then parts from it are used to create a String containing Key-Value-Pairs (like Param=EncodedPartOfUrl&Param2=EncondedPartofUrl&...) with (urlencode)

Now I want to decode it in Java. Can I use the URLDecoder for it or might there be a incompatibility? I also guess that in PHP there is no encoding scheme specified (when I understand the docs correctly) - how do I solve this then in java? Don't use a specified econding scheme (which is deprecated in Java 6 for URLDecoder)?

7
  • Are you doing this in a servlet or a jsp? Commented Jun 12, 2012 at 11:12
  • on the java side? none of both, I "receive" it as "data" Commented Jun 12, 2012 at 11:16
  • So this is not a java web application you're working with? A java SE(desktop) application then? Commented Jun 12, 2012 at 11:22
  • no, it is not a webapplication. Its simply a java program working with data and generating more data as output. ;-) Commented Jun 12, 2012 at 11:28
  • in that case please provide some code of how you're trying to do this so that someone may be able to help you. Commented Jun 12, 2012 at 11:38

1 Answer 1

1

Can't You just build Your URL, then url_encode it in PHP and then use Your URLDecoder in Java (or whatever it is)?

URL encoding just of values from Key-Value pairs is not enough and not quite good approach - You should URL encode the whole URL for this...

EDIT:

Thanks for your answer, but I have no influence there. I can only work on the java side of code.

Then You have the only possibility: parse the URL to get the GET parameters and URL decode each of their values separately...

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your answer, but I have no influence there. I can only work on the java side of code.
Thanks for your answer. thats what I thought. I parse the Parameters and then I decode. The question is, are there incompatibilities? What about the encodign scheme?
@nano7 If they use url_encode() on PHP side there should be no incompatibility as it preserves HTTP standards.
They use urlencode(), but I thought this creates platform specific results. In Java I can decide wether I use a specific encoding scheme or not. If I use an encoding scheme, maybe I would create wrong decoded results ? Not using an encoding scheme means using a deprecated method,,,
Then I am sorry cos I do not see into the Java UrlDecoder and cannot ell You whether there will be incompatibilities or not... You can only try and You'll see...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.