Chapter 12. Programming for the Web

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. But it’s important to note that standards and protocols, not the applications and tools themselves, have enabled the web’s growth. Since the earliest days of the internet, there have been ways to move files from here to there, and document formats that were just as powerful as HTML, but there was not a unifying model for how to identify, retrieve, and display information, nor was there a universal way for applications to interact with that data over the network. Since the web explosion began, HTML has reigned supreme as a common format for documents, and most developers have at least some familiarity with it. In this chapter, we’re going to talk a bit about its cousin, HTTP, the protocol that handles communications between web clients and servers, and URLs—Uniform Resource Locators—which provide a standard for naming and addressing objects on the web. Java provides a very simple API for working with URLs to address objects on the web. In this chapter, we’ll discuss how to write web clients that can interact with the servers using the HTTP GET and POST methods, and also say a bit about web services, which are the next step up the evolutionary chain. In “Java Web Applications”, we’ll jump over to the server ...

Get Learning Java, 5th 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.