P3.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W 3C //DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'p1.jsp' starting page</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
function login(){
var account = document.loginForm.account.value;
var password = document.loginForm.password.value;
var xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
xmlHttp.open("GET", "p4.jsp?account="+account+"&password="+password, true);
xmlHttp.onreadystatechange=function() {
if (xmlHttp.readyState==4) {
//xmlHttp.responseText纯粹表示p4.jsp输出的内容,
result.innerHTML = xmlHttp.responseText;
}
else{
result.innerHTML = "正在登陆,请稍等";
}
}
xmlHttp.send();
}
</SCRIPT>
请您登陆. <hr>
<form name="loginForm">
请您输入账号:<input type="text" name="account"><BR>
请您输入密码:<input type="password" name="password"><BR>
<input type="button" value="登陆" onclick="login()">
</form>
<div id="result"></div>
</body>
</html>
P4.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String account = request.getParameter("account");
String password = request.getParameter("password");
if(account.equals(password)){
out.print("<a href=ope.jsp>登陆成功,到达操作页面</a>");
}
else{
out.print("登陆失败");
}
%>