I have a Web application online running on a Linux server. I need to access 
files located on a private network running Windows server. The client has given 
me a public IP which uses port 8080 that I can use to access the reources that 
I need. 
 
If I type the IP plus the port in IE like so: http://[my ip addres]:8080 I get 
the prompt to enter the appropriate user and password. When I enter the user 
and password that were given to me by the client, I’m able to access the 
directories that I need. 
 
Now, I want to this from my application without user intervention. In other 
words, I want to be able to pass the IP, port, userid and password from within 
my routine and then access the necessary resources. 
 
I’ve been working with several samples but the result is always the same. When 
I run the JSP page, I get prompted for the userid and password. 
 
Could you please take a look at the code snippet and give me a heads-up. 
 
    HttpClient client = new HttpClient(); 
    // Set credentials on the client 
    Credentials credentials = new NTCredentials("userid", "password", 
                                                                         
"http://0.0.0.0:8080";, null); 
    //HttpState state = client.getState(); 
    //state().setCredentials(null, null, credentials); 
    client.getState().setCredentials(null, null, credentials); 
    String url = "http://0.0.0.0/PathToFiles";; 
    HttpMethod method = new GetMethod(url); 
    client.executeMethod(method); 
   
    // String responseStr = method.getResponseBodyAsString(); 
    // System.out.println(responseStr); 
    // method.releaseConnection(); 
 
    String redirectURL = "http://0.0.0.0:8080/PathToFiles"; ; 
    response.sendRedirect(response.encodeRedirectURL(redirectURL)); 
 
Thanks so much for the help
 
 


      

Reply via email to