URLs and the HTTP Conversation

In this section, we talk a bit about URLs and about the HTTP conversation between the user's web browser and your Tomcat server. An understanding of this material will be helpful in diagnosing certain types of errors and, at the end of the section, we show you several tools for watching the HTTP conversation; this allows you to pretend to be a web browser and see exactly how Tomcat is responding.

HTTP Requests

The recipient of any request is, of course, a URL. A URL, or Universal Resource Locator, is the standard form of web address and is understood by all web programs (including your web browser). A URL consists of a protocol, a hostname, an optional port number, a slash, and an optional resource path.

The first portion of the URL, the protocol, is generally the Hyper-Text Transport Protocol (HTTP). While there are several available protocols, HTTP is the network protocol that the web browser and web server most often use to communicate. The HTTP request consists of at least one line and usually some additional header lines. The request line consists of three parts: the request type (usually GET or POST), the path and name of the object being requested (often an HTML file or an image file, but this may also be a servlet or JSP, an audio or video file, or almost anything else), and the highest version number of the HTTP protocol that the browser is prepared to speak (usually 1.0 or 1.1). If the URL does not include any filename, the browser must send ...

Get Tomcat: The Definitive Guide, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.