Tomcat 사용. 서버에 문자열을 보내고 서버가 문자열을 조작 한 다음 다시 보내도록하려고합니다. 출력 스트림에 작성한 후 클라이언트에서 InputStream을 열려고 시도 할 때마다 응용 프로그램이 중단됩니다.Tomcat 오류 : java.io.IOException : 서버에서 HTTP 응답 코드 : 405를 반환했습니다.
서버 :
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException{
try{
ServletInputStream is = request.getInputStream();
ObjectInputStream ois = new ObjectInputStream(is);
String s = (String)ois.readObject();
is.close();
ois.close();
ServletOutputStream os = response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject("return: "+s);
oos.flush();
os.close();
oos.close();
}
catch(Exception e){
}
}
클라이언트 :
그것은이 오류를 반환URLConnection c = new URL("*****************").openConnection();
c.setDoInput(true);
c.setDoOutput(true);
c.connect();
OutputStream os = c.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject("This is the send");
oos.flush();
oos.close();
InputStream is = c.getInputStream();
ObjectInputStream ois = new ObjectInputStream(is);
System.out.println("ret: "+ois.readObject());
ois.close();
is.close();
os.close();
:
java.io.IOException: Server returned HTTP response code: 405 for URL:
http://mywebpage.com
무엇이 오류의 원인이되는, 내가 잘못하고있는 중이 야 무엇을?
가능한 복제본 [doGet 및 doPost String = null 문제] (http://stackoverflow.com/questions/18162280/detect-and-dopost-string-null-issue) –