2012-08-09 113 views
0

我從應用程序運行時得到以下異常,但是當我作爲獨立運行時,我得到了其餘的調用響應位置幫助我解決了這個問題。服務器重定向太多次

java.net.ProtocolException:服務器重定向次數過多(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(); 
     } 
    } 

回答

0

在所有的可能性,你已經在服務器中輸入重定向循環。服務器響應303 See other,並且當Java的URL連接實現自動「看到其他」時,服務器再次以相同的響應進行響應,從而無限次地進行響應。

相關問題