0

I get the below exception when running from application but when i run as stand alone i get the rest call response place help me solve this problem.

java.net.ProtocolException: Server redirected too many times (20)

public static void main(String args[]) throws Exception{
        String input = new String();
        Authenticator.setDefault(new MyAuthenticator());
        StringBuffer url = new StringBuffer();
        url.append("https://rest-call-server-URL");
        URL page;
        try {
            page = new URL(url.toString());
            URLConnection conn = (URLConnection) page.openConnection();
            conn.connect();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    conn.getInputStream()));
            String inputLine;

            while ((inputLine = in.readLine()) != null) {

                input+=inputLine;

                System.out.println(inputLine);
            }
            in.close();
//          out.close();
            //parseXmlList(input);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
4

1 に答える 1

0

おそらく、サーバーでリダイレクト ループに入っています。サーバーが応答し303 See other、Java の URL 接続の実装が自動的に「他のことを認識」すると、サーバーは同じ応答で再び応答し、以下同様に無限に続きます。

于 2012-08-09T20:35:31.607 に答える