添加页面。
<%@ 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>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/studentAdd.js"></script>
<style type="text/css">
h1 {
color: #62a8ea;
}
tr, td {
color: gray;
}
.submit {
color: #62a8ea
}
.button {
color: #62a8ea
}
</style>
</head>
<body>
<h1>添加页面</h1>
<hr>
<form
action="<%=request.getContextPath()%>/StudentServlet?function=addStudent"
onsubmit="return verify();" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" id="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="text" name="password" id="password"></td>
</tr>
<tr>
<td>姓名:</td>
<td><input type="text" name="name" id="name"></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="radio" name="gender" value="男">男 <input
type="radio" name="gender" value="女">女</td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text" name="age" id="age"></td>
</tr>
<tr>
<td>地址:</td>
<td><input type="text" name="address" id="address"></td>
</tr>
<tr>
<td>日期:</td>
<td><input type="text" name="regdate" id="regdate"></td>
</tr>
<tr>
<td><input class="submit" type="submit" value="提交"></td>
<td><input class="button" type="button" value="取消"
onclick="cancel();"></td>
</tr>
</table>
</form>
</body>
</html>
修改页面。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/studentAlter.js"></script>
<style type="text/css">
h1 {
color: #62a8ea;
}
tr, td {
color: gray;
}
.submit {
color: #62a8ea
}
.button {
color: #62a8ea
}
</style>
<body>
<h1>修改页面</h1>
<hr>
<form
action="<%=request.getContextPath()%>/StudentServlet?function=alterStudent"
onsubmit="return verify();" method="post">
<table>
<tr>
<td><input type="text" style="display: none;" name="id" id="id"
value="${student.id }"></td>
</tr>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" id="username"
value="${student.username }"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="text" name="password" id="password"
value="${student.password }"></td>
</tr>
<tr>
<td>姓名:</td>
<td><input type="text" name="name" id="name"
value="${student.name }"></td>
</tr>
<tr>
<td>性别:</td>
<td><c:if test="${student.gender =='男'}">
<input type="radio" checked="checked" name="gender" value="男">男
<input type="radio" name="gender" value="女">女
</c:if> <c:if test="${student.gender =='女'}">
<input type="radio" name="gender" value="男">男
<input type="radio" checked="checked" name="gender" value="女">女
</c:if></td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text" name="age" id="age"
value="${student.age }"></td>
</tr>
<tr>
<td>地址:</td>
<td><input type="text" name="address" id="address"
value="${student.address }"></td>
</tr>
<tr>
<td>日期:</td>
<td><input type="text" name="regdate" id="regdate"
value="${student.regdate }"></td>
</tr>
<tr>
<td><input class="submit" type="submit" value="提交"></td>
<td><input class="button" type="button" value="取消"
onclick="cancel();"></td>
</tr>
</table>
</form>
</body>
</html>
整体显示页面。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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>
<style type="text/css">
#main {
margin-left: 150px;
margin-top: 80px;
}
table {
border: solid #62a8ea;
}
th, td {
height: 30px;
width: 80px;
text-align: center;
color: gray;
}
th {
color: #62a8ea;
}
a {
text-decoration: none;
}
#add_div {
margin-left: 726px;
}
#add_input {
border: 3px solid green;
padding-bottom: 4px;
padding-top: 4px;
padding-left: 8px;
padding-right: 8px;
}
</style>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/studentList.js">
</script>
</head>
<body>
<div id="main">
<div id="add_div">
<input id="add_input" type="button" onclick="goAdd();" value="增加">
</div>
<div id="table">
<table border="1px solid gray">
<tr>
<th>编号</th>
<th>用户名</th>
<th>密码</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>地址</th>
<th>日期</th>
<th>操作</th>
</tr>
<c:forEach var="student" items="${ students}">
<tr>
<td>${ student.id}</td>
<td>${ student.username}</td>
<td>${ student.password}</td>
<td>${ student.name}</td>
<td>${ student.gender}</td>
<td>${ student.age}</td>
<td>${ student.address}</td>
<td>${ student.regdate}</td>
<td><a style="color: orange;"
href="http://localhost:8080/studentManager/StudentServlet?function=delStudent&id=${student.id}">删除</a><a
style="color: blue;"
href="http://localhost:8080/studentManager/StudentServlet?function=goAlter&id=${student.id}">修改</a></td>
</tr>
</c:forEach>
</table>
</div>
</div>
</body>
</html>
登陆页面。
<%@page import="java.net.URLEncoder"%>
<%@ 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>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/login.js"></script>
</head>
<style type="text/css">
#body {
background: orange;
}
#title {
background: graytext;
text-align: center;
}
</style>
<body>
<%
Object errorMessage = session.getAttribute("errorMessage");
out.print(errorMessage);
%>
<%
String username = "";
String password = "";
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {
if (cookie.getName().equals("username")) {
username = URLEncoder.encode(cookie.getValue(), "utf-8");
}
if (cookie.getName().equals("password")) {
password = URLEncoder.encode(cookie.getValue(), "utf-8");
}
}
%>
<div id="body">
<div id="title">
<h1>登陆页面</h1>
<hr>
</div>
<form
action="<%=request.getContextPath()%>/LoginServlet?function=login"
onsubmit="return login();" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" id="username" name="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="text" id="password" name="password"></td>
</tr>
<tr>
<td><input type="checkbox" checked="checked" name="remember"
value="1"></td>
<td>记住我的选择</td>
</tr>
<tr>
<td><input type="submit" value="登陆"></td>
<td><input type="button" value="注册" onclick="reRegister();"></td>
</tr>
</table>
</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>
<style type="text/css">
#body {
background: orange;
}
</style>
<body>
<div id="body">
<h1>登陆成功</h1>
<hr>
</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>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/register.js"></script>
<style type="text/css">
#body {
background: orange;
}
#title {
background: graytext;
text-align: center;
}
</style>
</head>
<body>
<div id="body">
<div id="title">
<h1>注册页面</h1>
<hr>
</div>
<form
action="<%=request.getContextPath()%>/RegisterServlet?function=register"
onsubmit=" return register();" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" id="username" name="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" id="password" name="password"></td>
</tr>
<tr>
<td>姓名:</td>
<td><input type="text" id="name" name="name"></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="radio" name="gender" value="男">男 <input
type="radio" name="gender" value="女">女</td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text" name="age"></td>
</tr>
<tr>
<td>地址:</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td>注册时间:</td>
<td><input type="text" name="regdate"></td>
</tr>
<tr>
<td><input type="submit" value="提交"></td>
<td><input type="button" value="取消" onclick="cancle();"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
注册状态页面。
<%@page import="com.wh.action.RegisterServlet"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
import="com.wh.utils.RegisterStatus " 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>
<style type="text/css">
#body {
background: orange;
}
#title {
background: graytext;
text-align: center;
}
.href{
color: orange;
}
</style>
<body>
<div id="body">
<div id="title">
<h1>注册状态页面</h1>
<hr>
</div>
<%
RegisterStatus status = (RegisterStatus) request.getAttribute("rs");
String contextPath = request.getContextPath();
if (RegisterStatus.SUCCESS == status) {
out.print("<h1>注册成功</h1><a href=" + contextPath + "/LoginServlet?function=reLogin>请点击登陆<a>");
} else if (RegisterStatus.FAILURE == status) {
out.print("<h2>注册失败</h2><a href=" + contextPath + "/RegisterServlet?function=reRegister>请点击重新注册<a>");
} else if (RegisterStatus.REAISTERED == status) {
out.print("<h3>已注册</h3><a href=" + contextPath + "/RegisterServlet?function=reRegister>请点击重新注册<a>");
}
%>
</div>
</body>
</html>