Post Method




What exactly do you expect? As far as I can see the request is working (response code 200).
If I understand your code correctly you first get the input here:

var inputLine = it.readLine() // this sets the inputLine to "0 results"

Then you enter the while loop, because inputLine is not null. You add it to response and then you read the next line, which does not exist so it’s set to null.

I think your confusion comes from the fact that you only print inputLine after you ask for the second line. The first result of readLine does not get printed on its own.


I am passing value to the URL so, in the back end it will insert data. If I pass the URL and data manually from the browser then its working fine but If I do via this method then post is not working.


I’m not an expert on the HTTP protocol, but from what I can remember don’t need to send the ? as part of the request.
Also, if the back end is yours, you might want to take a look at what you are receiving there. Maybe this can give you a clue as to what goes wrong. I doubt though, that it’s a bug in the URL library as it’s part of the java std-lib and therefor get’s used by millions of programs.