フォームを持つ JSP ページがあり、送信時にデータベースからさらにデータを取得するサーブレットを呼び出します。必要なデータをすべて取得したら、すべてのデータを含む URL を作成し、データを処理して文字列応答を返す別のサイトから JSP ページを呼び出す必要があります。次に、応答を解析し、適切なメッセージを UI に表示する必要があります。
HTTPUrlConnection を使用してデータ アクセス レイヤーから JSP ページを呼び出そうとしましたが、HTTP 505 error
.
try{
URL url = new URL(mainURL+urlSB.toString());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.connect();
InputStreamReader isr = new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8"));
BufferedReader br = new BufferedReader(isr);
String htmlText = "";
String nextLine = "";
while ((nextLine = br.readLine()) != null){
htmlText = htmlText + nextLine;
}
System.out.println(htmlText);
}catch(MalformedURLException murle){
System.err.println("MalformedURLException: "+ murle.getMessage());
}catch(IOException ioe){
System.err.println("IOException: "+ ioe.getMessage());
}
次に、サーブレットへのURLを取得して使用し、取得していrequest.getRequestDispatcher(url).include(request, response)
ますjavax.servlet.ServletException: File "/http:/xxxx:8090/test/create.jsp" not found
私が確認したところ、別のサイトが稼働しています。他のサイトにアクセスできないため、デバッグできません。
何が間違っているのか、何が欠けているのか誰でも説明できますか?