ulmaxy ulmaxy - 4 months ago 42x
Java Question

Send HTTP POST request to destination by IP address in java

I have an Apache web server launched at another computer in my local network, that have a .php file in its root folder, so I can send my requests from browser using addresses like "". I really need to do that from my java code, which is kind of confusing for me. Since I'm using IP address, I can't use HttpUrlConnection to send my requests because it requires to have a URL. Is there something similar to HttpUrlConnection but for IP addresses?


HttpUrlConnection can be perfectly used for both hostname HTTP connections and for IP address HTTP connections:

HttpURLConnection conn = (HttpURLConnection) new URL("").openConnection();