サーブレットtext.javaがhtmlコンテンツをjspページindex.jspに返すとします。
のindex.jsp
<button onclick="location.href='text'">CLICK</button>
のtext.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<b>HELLO</b>");
} finally {
out.close();
}
}
ここで、サーブレットがWebブラウザーの要求に応答すると言います。ボタンをクリックした後、jspページの代わりにURLにサーブレットの名前があり、コントロールがjspページに戻されないのはなぜですか。
それはajax(formelement.innerHTML = ob.responseText())でのみ可能ですか?//ここでvarob= new XMLHttpRequest();