首页界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
.main{
width:400px;
height:600px;
border:1px solid #ccc;
margin:0 outo;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<div class="main">
<h1>用户登录窗口</h1>
<form name="regist" method="post" action="ctrl.jsp">
用户名:<input type="text" name="username">
密码:<input type="password" name="paw">
<input type="submit" name="登录">
<input type="reset" name="重置">
</form>
</div>
</body>
</html>
比对用户名和密码是否相同,相应跳转到输入正确或错误的界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String use = request.getParameter("username");
String paw1 = request.getParameter("paw");
if(use.equals("tom")&&paw1.equals("123456")){%>
<jsp:forward page="succe.jsp"/>
<%}else{%>
<jsp:forward page="error.jsp"/>
<% }
%>
</body>
</html>
用户名和密码输入正确的跳转界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String use1 = request.getParameter("username");
String paw2 = request.getParameter("paw");
%>
<h1>登录成功</h1>
<p>用户名:<%=use1 %></p>
<p>密码: <%=paw2 %></p>
</body>
</html>
用户名和密码输入错误的跳转界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>用户名或密码错误请重新输入</h1>
</body>
</html>