当我调用 RequestDispatcher 时,不是处理请求,而是将 JSP 页面本身呈现为输出...... JSP 内容出现在“帐户已创建”行之后。
//Servlet 块
if(i==1){
PrintWriter pw = response.getWriter();
pw.println("Account Created!!");
RequestDispatcher rd = request.getRequestDispatcher("Login.jsp");
rd.include(request, response);
System.out.println("Record Updated!!!");
}
//在浏览器上呈现的输出:
Account Created!!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<link rel="icon" type="image/ico" href="favicon.ico"></link>
<link rel="shortcut icon" href="favicon.ico"></link>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
<form action="./Authentication" method="post">
<p>Enter username<input type="text" name="Uname"></p>
<p>Enter password<input type="password" name="Pword"></p>
<input type="submit" value="Login">
</form>
</body>
</html>