在界面1中输入账号和密码,进行登录。若账号和密码正确,则认为登录到界面2,在界面2中输入姓名,提交后,在界面3中输出姓名和密码。
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
欢迎登录
<script type="text/javascript">
function validate(){
if(loginForm.account.value!=""&&loginForm.password.value!=""&&loginForm.account.value==loginForm.password.value){
alert("登录成功");
loginForm.submit();
return;
}else{
alert("登录失败");
return;
}
}
</script>
<form name="loginForm" action="ans05_1.jsp" >
请输入账号:<input name="account" type="text"><br>
请输入密码:<input name="password" type="password"><br>
<input type="button" value="登录" onClick="validate()">
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<%
String account1=request.getParameter("account");
%>
<form action="ans05_2.jsp" method="post">
<input name="useraccount" type="hidden" value="<%=account1%>">
已登录成功,请输入用户姓名:<input name="username" type="text"><br>
<input type="submit" value="确认">
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<%
String account2=request.getParameter("useraccount");
String name=request.getParameter("username");
out.println("用户的账号:"+account2);
out.println("用户的姓名:"+name);
%>
</body>
</html>