POSTを介してXMLファイル(xml形式の文字列)を別のサーブレットに送信するサーブレットを作成しようとしています。(必須ではないxml生成コードは「Hellothere」に置き換えられました)
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();
これによりサーバーエラーが発生し、2番目のサーブレットが呼び出されることはありません。