commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <>
Subject RE: HttpClient development
Date Mon, 06 May 2002 21:47:32 GMT
On Mon, 2002-05-06 at 17:43, Donald Ball wrote:

> anyway, attached is a short usage sample document for HttpClient. i'll
> see about fleshing it out if anyone has any comments.

er, okay, looks like jakarta's mail server silently drops attachments.
here it is inline.

- donald

<?xml version="1.0"?>
    <author email="">Commons Documentation Team</author>
    <author email="">Donald Ball</author>
    <section name="Usage">
      <p>Here is a short example program to help you get up to speed with HttpClient.
It checks to see if a resource exists using the <code>HEAD</code> method.</p>
public boolean testURL(String url) {

    HttpMultiClient client = new HttpMultiClient();
    HttpUrlMethod method = null;
    int status = -1;

    try {
        method = new UrlHeadMethod(url);
    } catch (MalformedURLException e) {
        throw new RuntimeException("Could not test malformed URL: "+
                                   url + ": " + e.getMessage());
    status = client.executeMethod(method);
    return (status == HttpStatus.SC_OK);

      <p>If you have many requests to make, you will probably want to reuse these objects.
<code>HttpMultiClient</code>'s executeMethod method is threadsafe, while the <code>HttpUrlMethod</code>
objects can be recycled after they're used.</p>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message