Dave, What kind of authentication does the target server expect: basic|digest|NTLM or form-based? At the moment it is not quite clear what is going on on the server side. If you posted a wire log of the HTTP session that exhibits the problem, I believe I would be able to tell more. See HttpClient logging guide for details <http://jakarta.apache.org/commons/httpclient/logging.html>
Oleg -----Original Message----- From: D Alvarado [mailto:[EMAIL PROTECTED] Sent: Thursday, January 22, 2004 23:26 To: [EMAIL PROTECTED] Subject: I'm a big loser 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]