Client/server development using standard Java classes
Specifically, we will use the HttpURLConnection
and HTTPServer
classes to implement a client and server application. These classes support much of the functionality required for clients and servers. Using these classes will avoid writing low-level code to implement HTTP functionality. Low-level code refers to the non-specialized classes, such as the Socket
class. Higher-level and more specialized classes, such as the HttpURLConnection
and HTTPServer
classes, supplement and provide additional support for specialized operations.
The HttpURLConnection
class is derived from the HttpConnection
class. This base class has a number of methods that not are directly concerned with the HTTP protocol.
Using the HttpURLConnection class
The HttpURLConnection
class provides a convenient technique to access a web server. With this class, we can connect to a site, make a request, and access the respond headers and the response message.
We will use the HttpURLConnectionExample...