Chapter 13. Network Programming in Java

When you think about the web, you probably think of web-based applications and services. If you are asked to go deeper, you may consider tools such as web browsers and web servers that support those applications and move data around the network. In this chapter, we’ll look at how Java interacts with web services. We’ll also peek under the hood a bit and discuss some of the lower-level networking classes of the java.net package.

Uniform Resource Locators

A Uniform Resource Locator (URL) points to an object on the internet. It’s a text string that identifies an item, tells you where to find it, and specifies a method for communicating with it or retrieving it from its source. A URL can point to any kind of information source: static data, such as a file on a local filesystem, a web server, or an FTP site. It can point to a more dynamic object, such as an RSS news feed or a record in a database. URLs can also refer to other resources, such as email addresses.

Because there are many different ways to locate an item on the internet, and different mediums and transports require different kinds of information, URLs can have many forms. The most common form has four components as shown in Figure 13-1: a network host or server, the name of the item, its location on that host, and a protocol by which the host should communicate.

ljv6 1301
Figure 13-1. Common ...

Get Learning Java, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.