From my web application I am doing a redirect to an external URL which has some credentials as a part of the URL string. I would like to encode the credential part alone before redirection. I have the following URL:
String url1 = "http://servername:7778/reports/rwservlet?server=server1&ORACLE_SHUTDOWN=YES&PARAMFORM=no&report=test.rdf&desformat=pdf&desname=test.pdf&destype=cache¶m1=56738&faces-redirect=true&";
I am encoding it as:
String URL = "userid=username/passwd@DBname";
encodedURL = URLEncoder.encode(URL, "UTF-8");
String redirectURL = url1 + encodedURL1;
The URL generated by this code is
http://servername:7778/reports/rwservlet?server=server1&ORACLE_SHUTDOWN=YES&PARAMFORM=no&report=test.rdf&desformat=pdf&desname=test.pdf&destype=cache¶m1=56738&faces-redirect=true&userid=%3Dusername%2Fpasswd%40DBname
As we can see towards the end of the encoded URL, only the special characters like / have been encoded. i.e. userid=username/passwd@DBname has become userid=%3Dusername%2Fpasswd%40DBname
I want to generate a URL which will have the the entire string "username/passwd@DBname" encoded . Something like :
userid=%61%62
How can I achieve this?