0

I have a url I need to include in another. So far I have:

String urlString = "http://company.com/action?sourceUrl=http://stackoverflow.com/foo"
URL url = new URL(urlString);

How can I make sure this url does not get messed up? I mean for example, what if I need another parameter:

String urlString = "http://company.com/action?sourceUrl=http://stackoverflow.com/foo&count=1"
URL url = new URL(urlString);

This is now ambiguous. Does count belong to the outer URL, or inner? How do I solve this situation, and in general up one URL in another and then issue the request in Java?

David Williams
  • 8,388
  • 23
  • 83
  • 171
  • 1
    Encode the source URL parameter with URLEncoder.... – SJuan76 Nov 06 '13 at 02:44
  • 1
    You will need to encode the 2nd URL. See this answer: http://stackoverflow.com/questions/444112/how-do-i-encode-uri-parameter-values – KennyC Nov 06 '13 at 02:47

0 Answers0