这是我的程序
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的位置就会出现这个异常,为什么???
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的位置就会出现这个异常,为什么???
我记的我用这个类的时候 没写过connection.connect();
你去掉这个试一下看看可以不啊?