cancel
Showing results for 
Search instead for 
Did you mean: 

Error while reading from a URL

former_member312910
Participant
0 Kudos

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");

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

}

// urlc.setDoOutput(true);

urlc.setDoInput(true);

urlc.setUseCaches(false);

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

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

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

String line;

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

{

wdComponentAPI.getMessageManager().reportSuccess(line);

}

Any help is appreciated

Deepu

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member192434
Active Contributor
0 Kudos

Hi

That becouse of when you are accessing that URL from local it is directiong it to the server....that's fine..but whenever you start accessing it form Server..ance again it is redirecting to the server. ie why it is giving the problem,

Put the candition whenever you accessing it from server not to redirect to sever.

http://help.sap.com/SAPHELP_NW04S/helpdata/EN/2f/e7574174c58547e10000000a1550b0/frameset.htm

Thanks