POST를 통해 XML 파일 (XML 형식의 문자열)을 다른 서블릿에 보낼 서블릿을 작성하려고합니다. 한 자바 서블릿에서 다른 서블릿으로 게시물 데이터 작성
StringBuilder sb= new StringBuilder();
sb.append("Hello there");
URL url = new URL("theservlet's URL");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Length", "" + sb.length());
OutputStreamWriter outputWriter = new OutputStreamWriter(connection.getOutputStream());
outputWriter.write(sb.toString());
outputWriter.flush();
outputWriter.close();
이 서버 오류를 일으키는 (비 필수 XML을 생성하는 코드는 "안녕하세요"로 대체), 두 번째 서블릿이 호출되지 않습니다.