hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "D Alvarado" <laredotorn...@wildmail.com>
Subject I'm a big loser
Date Thu, 22 Jan 2004 22:26:15 GMT
I can't seem to figure out how to POST data to a
page that is protected (puts up a gray box where
you enter the username/password).  The code below
is in a servlet running on www.mydomain.com and
submitting to another page also on www.mydomain.com.

        // Create an instance of HttpClient.
        HttpClient client = new HttpClient();
        // submit username/password for the gray box.
       
client.getState().setAuthenticationPreemptive(true);
        UsernamePasswordCredentials creds = new
UsernamePasswordCredentials("username", "password");
        client.getState().setCredentials(null,
request.getServerName(), creds);

        // Now submit this file to the piece that
uploads batch files.
        String targetURL = "http://" +
request.getServerName() +
"/hrw/ecom/HRWImportCOPSData";
        MultipartPostMethod method = new
MultipartPostMethod(targetURL);
        method.addParameter("import_file",
completeEcomFile.getName(), completeEcomFile);
        method.setDoAuthentication(true);

but when I try to submit the request using

statusCode = client.executeMethod(method);

I repeatedly get the exception "Connection
refused."  I'm pretty sure the authentication is
being required by the Apache webserver.  Any help
is greatly appreciated - Dave


Care2 make the world greener!
Eighty-six nations have signed the international Framework Convention on Tobacco Control.
Help get the U.S. on the list! http://www.care2.com/go/z/10840/1060

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message