How to Decode and Encode a url ? I have this short url an I want to encode that
http://test.com/en/test/93043017523/xxx-yyy-zzz
after a while I found this solution
java.net.URLEncoder.encode(myurl, "UTF-8");
How to Decode and Encode a url ? I have this short url an I want to encode that
http://test.com/en/test/93043017523/xxx-yyy-zzz
after a while I found this solution
java.net.URLEncoder.encode(myurl, "UTF-8");
Use this online tool for URL encoding: http://meyerweb.com/eric/tools/dencoder/
JS: and also check out the built-in function encodeURIComponent(str) and encodeURI(str). In your case, this should work:
var myOtherUrl =
"http://test.com/en/test/93043017523/" + encodeURIComponent("xxx-yyy-zzz");
JAVA: In java use this URLEncoder.encode() method:
String url = "http://test.com/en/test/93043017523/" + URLEncoder.encode("xxx-yyy-zzz");
HttpGet does not support redirects which might be causing the issue. The default behaviour is compliant with the requirements of the HTTP specification (RFC 2616)
Have you tried the HttpClient? For HttpClient 4.3 you can use the following code snippet to allow redirects:
HttpClient instance = HttpClientBuilder.create()
.setRedirectStrategy(new LaxRedirectStrategy()).build();