Use Case: Access some URLs

Description

I have some URLs, and want to access those documents in my application.

Background

This is the most obvious use of an HTTP client component. It is important for the ease of use of the API.
This use case is about a list of URLs rather than a single URL to highlight the difference between initializations and per-access activities.

Variations

  1. I want to save the documents to the file system, too.

Discussion

There is a trade-off between ease of use and flexibility. The standard Java library provides the required functionality for this use case in the java.net package through the URL and HttpURLConnection classes. These are easy to use, but exhibit major drawbacks once you require flexibility.

The HttpClient project was originally started because HttpURLConnection is not good enough. HttpClient is not and will hardly ever be as easy to use. That said, it still shouldn't be unnecessary hard to use either.

If accessing documents is your only concern you may be better off using the Java built-in stuff. But as soon as you have to deal with timeouts, error handling, different cookie specs, connection management, multiple user sessions and all kinds of stuff, HttpClient starts to shine.

Solution

Standard Solution

Additional preparations are required to make this solution work for HTTPS.

Bare Bones Solution

The bare bones solution will not work for HTTPS.

Variation: Save to File System

in addition to one of the solutions above,...

UseCases/AccessURLs (last edited 2009-09-20 21:46:17 by localhost)