获取java.net.ProtocolException:服务器重定向次数过多(20)

时间:2012-02-14 17:49:44

标签: java http exception

我正在发出像这样的HTTP请求

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.222.111.77", 5150));
URL url;
    try {
        url = new URL("http://127.0.0.1:9080/myApp/basictest.jsp");

        HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);

        uc.connect();

        String line = "";        

        StringBuffer tmp = new StringBuffer();
        BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
        while ((line = in.readLine()) != null){
           page=page+(line + "\n");
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block

        e.printStackTrace();
    }

at uc.getInputStream()我将服务器重定向错误次数太多了。

我可以从浏览器访问网址http://127.0.0.1:9080/myApp/basictest.jsp,我可以用google.com或yahoo.com替换此网址,我的代码可以进行http调用并打印返回的代码。但是在127.0.0.1:9080/myApp上对我的服务器的任何调用都会在通过代码进行调用时返回此错误(来自浏览器可以访问)

0 个答案:

没有答案