URL-based communication
Nowadays, it seems that everybody has some notion of a URL; those who use a browser on their computers or smartphones will see URLs every day. In this section, we will briefly explain the different parts that make up a URL and demonstrate how it can be used programmatically to request data from a website (or a file) or to send (post) data to a website.
The URL syntax
Generally speaking, the URL syntax complies with the syntax of a Uniform Resource Identifier (URI) that has the following format:
scheme:[//authority]path[?query][#fragment]
The square brackets indicate that the component is optional. This means that a URI will consist of scheme:path
at the very least. The scheme
component can be http
, https
, ftp
, mailto
, file
, data
, or another value. The path
component consists of a sequence of path segments separated by a slash (/
). Here is an example of a URL consisting only of scheme
and path
:
file:src/main/resources/hello.txt
The preceding...