版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38262266/article/details/86618631
login.jsp
<%@ page contentType="text/html; charset=GB2312" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>用户登录</title>
</head>
<element>
<body>
<center>
<form name="form" method="post" action="check.jsp">
<table width="600" height="300" border="5"
align="middle">
<caption>
<h2>用户登录</h2>
</caption>
<tr>
<td align="center" valign="middle">
<h3>姓名</h3>
</td>
<td align="center" valign="middle">
<h3>
输入信息:
<input name="name" type="text"></h3>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<h3>密码</h3>
</td>
<td align="center" valign="middle">
<h3>
输入信息:
<input name="password"
type="text"></h3>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<h3>是否确认:</h3>
</td>
<td align="center" valign="middle">
<h3>
<input name="secret" type="submit"
value="确认提交"></h3>
</td>
</tr>
</table>
</element>
</form>
</center>
</body>
</html>
check.jsp
<%@ page contentType="text/html; charset=GB2312" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>用户登录</title>
</head>
<element>
<body>
<%
request.setCharacterEncoding("GB2312");
String name = request.getParameter("name");
session.setAttribute("name",name);
String password = (String)request.getParameter("password");
session.setAttribute("password",password);
if(name.equals("张三")&&password.equals("1234")) {
response.sendRedirect("final.jsp");
%>
<%} else%>
<center>
<h1>
<%="用户名或密码错误!"%>
</h1>
</center>
<center>
<h2>
<a href="login.jsp">重新登录</a>
</h2>
</center>
</body>
</element>
</html>
final.jsp
<%@ page contentType="text/html; charset=GB2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>用户登录</title>
</head>
<element>
<body>
<%
String name = (String)session.getAttribute("name");
String password = (String)session.getAttribute("password");
%>
<center>
<form name="form1" method="post">
<table width="600" height="300" border="5"
align="middle">
<caption>
<h2>用户信息:</h2>
</caption>
<tr>
<td align="center" valign="middle">
<h3>姓名</h3>
</td>
<td align="center" valign="middle">
<h3>
输出信息:
<%=name%>
</h3>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<h3>密码</h3>
</td>
<td align="center" valign="middle">
<h3>
输出信息:
<%=password%>
</h3>
</td>
</tr>
</form>
</center>
</body>
</element>
</html>