这是我的程序
   URL url = new URL("http://10.204.38.90:8888/choicePhoneNo/choicePhone");
                HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //1
                System.out.println("get connetion suucessfully");
                connection.setDoOutput(true);
                connection.setRequestMethod("POST");
                connection.connect();    //2                OutputStream s = connection.getOutputStream()//3这段代码在我的笔记本上运行正常,打成jar包放到服务器上,就出现以下异常:
java.net.ProtocolException: You cannot get an output stream for an existing http connection
   at gnu.java.net.protocol.http.Connection.getOutputStream() (/usr/lib/libgcj.so.5.0.0)
   at test.Test.main(java.lang.String[]) (Unknown Source)我的服务器是可以ping通那个连接ip的,程序是可以正常执行到2的位置的,到3的位置就会出现这个异常,为什么???

解决方案 »

  1.   

    好长时间没看这些网络的东西了。
    我记的我用这个类的时候 没写过connection.connect(); 
    你去掉这个试一下看看可以不啊?
      

  2.   

    欢迎加入Java群 38797100 互相交流共同进步
      

  3.   

    我在window上有那个connection.connect();   2处就没有问题,在服务器上2处有问题,我去掉了,3处就出错了