Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am attempting to access a file wi

Status
Not open for further replies.

bucafett2000

Programmer
Jun 17, 2002
2
US
I am attempting to access a file with the java.net.URL data type in WAS on OS390 with athentication on.

Code:
Authenticator.setDefault(new BTSAuthenticator());    
URL url = new URL("[URL unfurl="true"]http://mylocation/file.txt");[/URL]
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setFollowRedirects(false);
connection.connect();
InputStream input = connection.getInputStream();
...
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password".toCharArray());
}

I get java.net.ProtocolException: Server redirected too many times (5) when it gets to the getInputStream() call.

Any help on solving this would greatly be appreciated. Thanks!
Adam
 
Hi,

I am not a developer but I did manage to find a direct reference to this problem.

Replace

connection.setFollowRedirects(false);

with

((HttpURLConnection) conn).setInstanceFollowRedirects(false);

this subclasses it and overrides the limitation.

Does this help?

Regards,

Fearo

 
Unfortunately I am using this on WAS 3.5 and the JVM version IBM uses is 1.2.2. In that version setInstanceFollowRedirects(false) is not available.

Thanks for the suggestion though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top