Getting URL with java

Possible duplicates:
How to send an HTTP request in java?
How to use java.net.URLConnection to start and process HTTP requests?

using java, how can I hit any url?

for example, opening http://www.xyz.com/node1 in a browser will tell xyz.com that node1 has hit. therefore, in this java program (which sends the sms text, say, "node1" in the example above, built into the URL of the sms gateway server itself)

how can I achieve this without opening a browser or servlet.

+4
source share
2 answers

You can use HttpURLConnection .

But using it directly is redundant if you just want to load the specified URL. This guide shows how to open a URL.

It basically boils down to:

URL url = new URL("http://www.xyz.com/node1"); URLConnection conn = url.openConnection(); conn.connect(); //... 
+6
source

The easiest way is to use the URL http://download.oracle.com/javase/1.4.2/docs/api/java/net/URL.html . For a more advanced / flexible URL selection, you can use HttpClient http://hc.apache.org/httpclient-3.x/

0
source

All Articles