Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Error while reading from a URL

Hi All

When I am trying to read a URL I am getting the following error.

u201CServer redirected too many times (20)u201D

I get the error only when I run the code from a server application. When I execute the code locally in a java class, the code works with out any errors.

I printed the the Response code which was 401 (Unauthorized).

When i give the URL in the browser, the file opens without any problems.

This is the code that I have used

URL url = new URL( "http://hydhtc137407d/Test/Pdf1.pdf" );

URLConnection urlc = url.openConnection();

if (urlc instanceof HttpURLConnection) {

System.out.println("This is HttpURLConnection");



// urlc.setDoOutput(true);



// ((HttpURLConnection)urlc).setRequestMethod("GET");

bis = new BufferedInputStream( urlc.getInputStream());

BufferedReader br = new BufferedReader( new InputStreamReader(bis));

String line;

while ((line = br.readLine()) != null)




Any help is appreciated


Former Member
Not what you were looking for? View more on this topic or Ask a question