ok - i got it. i was authenticating it on 443 - now i have changed to the
appropriate port. it worked. thanks :)
..alee
http://techboard.wordpress.com



On Wed, Feb 4, 2009 at 6:51 PM, alee amin <[email protected]>wrote:

> 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
>
>

Reply via email to