Class of the Month: Making HTTP Connections

There are times when the resource your Java application needs is available from a Web site. You can see it by pointing your browser to its URL. You just need to have your application access it. The java.net.HttpURLConnection class will help you do just that.

provided by: 
Originally published at Internet.com


HTTP is the protocol that makes the Web click. It is generic enough to carry any type of data including HTML, raw data, image files, and XML. There are times when the resource your application needs is available from a Web site. You can see it by pointing your browser to its URL. You just need to have your Java application access it. The java.net.HttpURLConnection class will help you do just that. By encapsulating the HTTP protocol in a class, your application can interact with any resource that has an HTTP URL associated with it. This includes posting HTML forms to servlets and JSPs as if they were filled via a browser.

Piroz Mohseni

HttpURLConnection is an abstract class, so you can not directly instantiate it. When you create an instance of java.net.URL with an "http" URL and invoke its openConnection() method, you get an instance of HttpURLConnection. This instance will be your key to sending and receiving HTTP messages both directly or through a proxy server. Here is a code fragment that will result in creation of an instance of HttpURLConnection:

URL url = new URL("http://www.developer.com"); HttpURLConnection httpcon = url.openConnection(); ...

Read article at Internet.com site
Regional Articles
- Class of the Month: Making HTTP Connections Alabama
- Class of the Month: Making HTTP Connections Alaska
- Class of the Month: Making HTTP Connections Arizona
- Class of the Month: Making HTTP Connections Arkansas
- Class of the Month: Making HTTP Connections California
- Class of the Month: Making HTTP Connections Colorado
- Class of the Month: Making HTTP Connections Connecticut
- Class of the Month: Making HTTP Connections DC
- Class of the Month: Making HTTP Connections Delaware
- Class of the Month: Making HTTP Connections Florida
- Class of the Month: Making HTTP Connections Georgia
- Class of the Month: Making HTTP Connections Hawaii
- Class of the Month: Making HTTP Connections Idaho
- Class of the Month: Making HTTP Connections Illinois
- Class of the Month: Making HTTP Connections Indiana
- Class of the Month: Making HTTP Connections Iowa
- Class of the Month: Making HTTP Connections Kansas
- Class of the Month: Making HTTP Connections Kentucky
- Class of the Month: Making HTTP Connections Louisiana
- Class of the Month: Making HTTP Connections Maine
- Class of the Month: Making HTTP Connections Maryland
- Class of the Month: Making HTTP Connections Massachusetts
- Class of the Month: Making HTTP Connections Michigan
- Class of the Month: Making HTTP Connections Minnesota
- Class of the Month: Making HTTP Connections Mississippi
- Class of the Month: Making HTTP Connections Missouri
- Class of the Month: Making HTTP Connections Montana
- Class of the Month: Making HTTP Connections Nebraska
- Class of the Month: Making HTTP Connections Nevada
- Class of the Month: Making HTTP Connections New Hampshire
- Class of the Month: Making HTTP Connections New Jersey
- Class of the Month: Making HTTP Connections New Mexico
- Class of the Month: Making HTTP Connections New York
- Class of the Month: Making HTTP Connections North Carolina
- Class of the Month: Making HTTP Connections North Dakota
- Class of the Month: Making HTTP Connections Ohio
- Class of the Month: Making HTTP Connections Oklahoma
- Class of the Month: Making HTTP Connections Oregon
- Class of the Month: Making HTTP Connections Pennsylvania
- Class of the Month: Making HTTP Connections Rhode Island
- Class of the Month: Making HTTP Connections South Carolina
- Class of the Month: Making HTTP Connections South Dakota
- Class of the Month: Making HTTP Connections Tennessee
- Class of the Month: Making HTTP Connections Texas
- Class of the Month: Making HTTP Connections Utah
- Class of the Month: Making HTTP Connections Vermont
- Class of the Month: Making HTTP Connections Virginia
- Class of the Month: Making HTTP Connections Washington
- Class of the Month: Making HTTP Connections West Virginia
- Class of the Month: Making HTTP Connections Wisconsin
- Class of the Month: Making HTTP Connections Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML