[J2SE] tomcat改80 port
環境 eclipse + tomcat7
把Tomcat改80 port之後
eclipse中server端可以正常執行
但java使用HttpURLConnection連結到servlet之檔案
卻無法正常執行
程式碼如下
URL url = new URL("http://localhost/ServletServer/Server");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(),
"UTF-8");
out.write("username=kevin&password=pass");
out.flush();
out.close();
String strLine = "";
String strResponse = "";
InputStream in = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
while ((strLine = reader.readLine()) != null)
{
strResponse += strLine + "\n";
}
System.out.print(strResponse);
錯誤訊息為:
Exception in thread "main" java.io.IOException: Invalid Http response
或是
Exception in thread "main" java.net.SocketException: Software caused
connection abort: recv failed
但在預設的8080 port中
就可以執行正常
不會有任何錯誤
請問為什麼會這樣
敬請指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.100.86.102
推
07/28 15:16, , 1F
07/28 15:16, 1F
→
07/28 15:24, , 2F
07/28 15:24, 2F