Tuesday, June 21, 2016

RESTful Java client by using java.net.URL

Here we will use “java.net.URL” and “java.net.HttpURLConnection” to create a simple Java client to send “GET” and “POST” request.

GET Request

REST service that return “json” data back to client.


Java client to send a “GET” request:

Output:
Output from Server .... 
{"qty":999,"name":"iPad 3"}

NOTE: Same way, by using "POST" method  we can create Java Client using java.net.URL with few changes in the above code.

0 comments:

Post a Comment

Contact

Get in touch with me


Adress/Street

Bangalore, India