hi,
I am trying to send a request to my own website which is using basic
authentication method. But i am unable to to authenticate it through
httpclient
here is the code i am using
HttpClient httpClient = new HttpClient();
HttpMethod httpGet = new GetMethod("
http://localhost:8080/project-web/Servlet");
httpClient.getState().setCredentials(
new AuthScope("http://localhost:8080", 443, "realm"),
new UsernamePasswordCredentials("userName", "Password"));
httpGet.setDoAuthentication(true);
try{
int status = httpClient.executeMethod(httpGet);
byte[] response = httpGet.getResponseBody();
System.out.println("status: " + status);
System.out.println("response: " + new String(response));
}
catch (Exception ex){
}
There is no exception that is being raised. I am getting the status code 401
with "responseBody" having text ... "this request require authentication".
Am i missing something?
..alee
http://techboard.wordpress.com