Chapter 4

Using HttpClient

IN THIS CHAPTER

check Getting familiar with HTTP

check Dipping your toe into Java’s HttpClient library

check Seeing how it all fits together

check Looking at a simple Java program that uses HttpClient

The previous chapters in this minibook show you how to create programs specifically designed to run on a web server so they can be consumed by users on the web.

This chapter turns the tables: It shows you how to write Java programs that consume information provided by web servers. This is accomplished via a library that was introduced in Java 11 called the HttpClient.

Understanding HTTP

Before I dive into the details of the HttpClient, I need to explain what HTTP is and how it works. You need at least a basic understanding of HTTP to make the HttpClient work.

HTTP stands for HyperText Transfer Protocol. It was created way back in 1997 and quickly became the cornerstone of what we now know as the World Wide Web.

HTTP's initial purpose was to allow users to access HTML files from web servers. It quickly grew beyond that to support a wide variety of data types, such as images, sounds, ...

Get Java All-in-One For Dummies, 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.