How to send json data in url as request parameters in java

Sanjaya Liyanage picture Sanjaya Liyanage · Oct 24, 2014 · Viewed 38.1k times · Source

I want to send json data in url as below .

editTest.jsp?details=374889331-{"aNumber":2}

How can I do this?

Answer

eee picture eee · Oct 24, 2014

URL encode your details parameter:

String otherParameter = "374889331-";    
String jsonString = "{\"aNumber\":2}";

String url = "editTest.jsp?details=" + URLEncoder.encode(otherParameter + jsonString, "UTF-8");