In one blog post I wrote about how we can make HTTP requests and receive response in Java. That post was only about sending GET request. This time we will learn how to make POST (submitting form etc) request in Java. This post assumes that you are familiar with HttpURLConnection found in java.net package. If you are not please read this blog post http://random-stuff-mine.blogspot.com/2013/06/http-request-and-response-java.html HTTP POST request Lets say you entered username/password in a website and pressed "Login" button. Most probably the web browser makes a HTTP POST request containing your username/password. A simple POST request would look like this POST /path/to/script HTTP/1.1 User-Agent: RemzyHttpBot Content-Type: application/x-www-form-urlencoded Content-Length: 32 username=rameez&password=test In the above request you see that username and password are sent inside the request body and content-type of request is set to appl...
I document random stuff on this Blog. It can be a piece of code , my personal experience, a fun fact or anything else.