Hey all,

I need you help. I build a simple bean that retrieves
contents of a url. I get an error message saying
'Server redirected too many times (5)'

Did anyone encounter this before?

Thanx in advance

- Kostik



OUTPUT of JSP PAGE
-----------------------------------------
http://gtsweb.dev.global.chase.com/isp
URL initialized
Connection opened
java.net.ProtocolException: Server redirected too many times (5)



JSP Page
------------------------------------------------------------
<%@ page import = "net.http.FetchURL" %>
<jsp:useBean id="fetchurl" class="net.http.FetchURL" scope="request"/>
<%
     String url = "http://gtsweb.dev.global.chase.com";
     String lineDelim = "";

     StringBuffer sb = fetchurl.getContent(url, lineDelim);
%>
<html>
<body>
<font size=4>

<pre>
<%= sb.toString() %>
</pre>

</body>
</html>
-------------------------------------------------------------------------


JAVA BEAN
-------------------------------------------------
package net.http;

import java.net.*;
import java.io.*;

public class FetchURL {


public StringBuffer getContent(String sUrl, String lineDelim) {
     StringBuffer sb = new StringBuffer();
     URLConnection conn;
     BufferedReader reader;

     sb.append(sUrl).append(lineDelim);

     try {
          URL uUrl = new URL(sUrl);
          sb.append("URL initialized").append(lineDelim);
          conn = uUrl.openConnection();
          sb.append("Connection opened").append(lineDelim);
          reader = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
          sb.append("Input Stream Opened").append(lineDelim);

          String line = "";
          while((line = reader.readLine()) != null) {
               sb.append(line).append(lineDelim);
          }
     }catch(Exception e) {
          sb.append(e.toString());
     }

     return sb;
}


}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to