web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>add</servlet-name>
<servlet-class>com.cn.servlet.add</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>addm</servlet-name>
<servlet-class>com.cn.servlet.addm</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>com.cn.servlet.ImageServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>delByName</servlet-name>
<servlet-class>com.cn.servlet.delByName</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>update</servlet-name>
<servlet-class>com.cn.servlet.update</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description> <display-name>This is the display name of my J2EE component</display-name>
<servlet-name>tianjia</servlet-name>
<servlet-class>com.cn.servlet.tianjia</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>chaxun</servlet-name>
<servlet-class>com.cn.servlet.chaxun</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>StudentServlet</servlet-name>
<servlet-class>com.cn.servlet.StudentServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>XueServlet</servlet-name>
<servlet-class>com.cn.servlet.XueServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>Xuezhuce</servlet-name>
<servlet-class>com.cn.servlet.Xuezhuce</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>Xuechaxun</servlet-name>
<servlet-class>com.cn.servlet.Xuechaxun</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>StudentServlet1</servlet-name>
<servlet-class>com.cn.servlet.StudentServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>StudentServlet</servlet-name>
<url-pattern>/StudentServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>add</servlet-name>
<url-pattern>/add</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>addm</servlet-name>
<url-pattern>/addm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ImageServlet</servlet-name>
<url-pattern>/ImageServlet</url-pattern> </servlet-mapping>
<servlet-mapping>
<servlet-name>delByName</servlet-name>
<url-pattern>/delByName</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>update</servlet-name>
<url-pattern>/update</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>tianjia</servlet-name>
<url-pattern>/tianjia</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>chaxun</servlet-name>
<url-pattern>/chaxun</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XueServlet</servlet-name>
<url-pattern>/XueServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Xuezhuce</servlet-name>
<url-pattern>/Xuezhuce</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Xuechaxun</servlet-name>
<url-pattern>/Xuechaxun</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>StudentServlet1</servlet-name>
<url-pattern>/StudentServlet1</url-pattern>
</servlet-mapping></web-app>
查询
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'chaxun.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="c.jpg">
<form action="chaxun" method="post">
<center style="font-size:60px;padding-top:120px">查询页面</center>
<center style="font-size:30px;padding-top:100px"> 学生姓名:<input type="text" name="username"><br><br><br><br>
<input type="submit" value="提交">
<input type="reset" value="重置">
</center>
</form>
<a href="StudentServlet1">返回</a>
</body>
</html>
删除
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'delByName.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="55.jpg">
<form action="delByName">
<center style="font-size:50px;padding-top:240px;padding-left:90px;">删除页面</h1></center>
<center style="font-size:30px;padding-top:50px;padding-left:90px;">学生姓名:<input type="text" name="username"><br><br><br><br>
<input type="submit"value="提交">
<input type="reset" value="重置">
<a href="success.jsp">返回</a>
</form>
</center>
</body>
</html>
错误
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'error.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="12.jpg">
<div style="font-size:50px;padding-top:260px; height: 525px; width: 1060px;padding-left:100px;"> <span style='color:purple'> 不好意思!你登录失败!</div>
</body>
</html>
返回
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'fanhui.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="jj.jpg">
<div style="font-family:楷书;font-size:60px;padding-top:350px;padding-left:700px;"><span style='color:purple'>注册成功!!!</span> </div>
<div style="font-family:楷书;font-size:40px;padding-top:200px;padding-left:800px;"><span style='color:purple'><a href="index.jsp">返回</a>
</body>
</html>
主页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function reload(){
var time = new Date().getTime();
document.getElementById("imgId").src="ImageServlet?d="+time;
}
</script>
</head>
<body background="H.gif">
<center style="font-size:50px;"><span style='color:pink'>登录页面</span></center>
<br>
<br>
<br>
<br>
<form action="add" method="post">
<center style="font-size:30px;padding-top:120px;padding-right:300px;">
<span style='color:green'> 用户名: <input type="text" name="username" value="请输入用户名" style="height: 34px; width: 167px; "/><br/><br><br>
密 码:<input type="password" name="password" style="height: 36px; width: 165px; "/><br/><br><br>
<center style="padding-left:180px;padding-top:-21px">
验证码:<input type="text" name="checkCode" style="height: 31px; width: 163px; ">
<img src="ImageServlet" id="imgId"/>
<a href=" ">看不清楚</a><br/><br><br>
<a href="#" value="teacher">老师</a>
<a href="xuesheng.jsp" value="student">学生</a>
</center>
<br>
<br>
<input type="submit" value="登录"/>
<a href="zhuce.jsp" >注册</a>
</form>
</center>
</body>
</html>
分页
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'pager.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="s.jpg">
<c:choose>
<c:when test="${pb.pc eq 1 }">上一页 </c:when>
<c:otherwise><a href="${pb.url }&pc=${pb.pc-1}">上一页</a></c:otherwise>
</c:choose>
<c:choose>
<c:when test="${pb.pc<6 }">
<c:set var="begin" value="1"/>
<c:set var="end" value="${pb.tp }"/>
</c:when>
<c:otherwise>
<c:set var="begin" value="${pb.pc-2}"/>
<c:set var="end" value="${pb.pc+3 }"/>
<c:if test="${begin<1 }">
<c:set var="begin" value="1"/>
<c:set var="end" value="6"/>
</c:if>
<c:if test="${end>pb.tp }">
<c:set var="begin" value="${pb.pc-5 }"/>
<c:set var="end" value="${pb.tp }"/>
</c:if>
</c:otherwise>
</c:choose>
<c:forEach begin="${begin }" end="${end }" var="page">
<c:choose>
<c:when test="${pb.pc eq page }">${page } </c:when>
<c:otherwise><a href="${pb.url }&pc=${page}">${page }</a></c:otherwise>
</c:choose>
</c:forEach>
<c:choose>
<c:when test="${pb.pc eq 6 }">下一页</c:when>
<c:otherwise><a href="${pb.url }&pc=${pb.pc+1 }">下一页</a></c:otherwise>
</c:choose>
</body>
</html>
查询显示结果
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'showline.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="180.jpg" style="height: 498px; width: 1240px; ">
<center style="font-size:60px;padding-top:130px;padding-right:60px"><span style='color:purple'>查询内容如下</span></center>
<center><table>
<tr>
<td><h1>姓名:</h1></td>
<td><h1>学号:</h1></td>
<td><h1>性别:</h1></td>
<td><h1>成绩:</h1></td>
<td><h1>电话:</h1></td>
</tr>
<tr>
<td><h1>${student.username}</h1></td>
<td><h1>${student.password}</h1></td>
<td><h1>${student.sex}</h1></td>
<td><h1>${student.grade}</h1></td>
<td><h1>${student.tel}</h1></td>
</tr>
</table>
</center>
<center><a href="StudentServlet"><span style="color:green;"><h1>返回</h1></span></a></center>
</body>
</html>
登陆成功页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>学生信息管理系统</title>
<!-- <script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery-2.1.0.js"></script>
<script type="text/javascript">
function loadChilden(){
var selectedId = $("#selectOne option:selected").val();
alert(222);
window.location.href = selectedId;
}
</script>
-->
<style type="text/css">
h1{font-family:华文行楷;
font-size:50px;
}
body{
background-image:url(00.jpg);
background-repeat:repeat;
}
</style>
</head>
<body>
<h1>欢迎你!<%=session.getAttribute("username") %></h1>
<center style="font-size:40px;font-family:华文行楷"><span style="color:green">欢迎登陆学生信息管理系统</span></center><br><br>
<center style="padding-left:1100px;" ><a href="index.jsp">退出</center>
<center style="font-size:30px;padding-top:40px;font-family:华文琥珀;">
<a href="tianjia.jsp">添加</a>
<a href="delByName.jsp">删除</a>
<a href="update.jsp">更新</a>
<a href="xiugai.jsp">修改</a>
<a href="chaxun.jsp">查询</a>
<!--<c:if test="${ mark eq 1 }">-->
<!-- </c:if>
<select οnchange="loadChilden()" id="selectOne">
<option selected="selected">==选择操作==</option>
<option id ="tianjia" value="tianjia.jsp" >添加</option>
<option id ="delByName" value="delByName.jsp">删除</option>
<option id="update" value="update.jsp">更新</option>
<option id="xiugai" value="xiugai.jsp">修改</option>
<option id="chaxun" value="chaxun.jsp">查询</option>
</select>
-->
</center>
<br><br><br><br><br>
<center>
<table border = "2" bordercolor=black align="center" width=550px height=250px>
<tr>
<td><h3> 姓名:</h3></td>
<td> <h3>密码:</h3></td>
<td> <h3>性别:</h3></td>
<td><h3> 成绩:</h3></td>
<td> <h3>电话:</h3></td>
</tr>
<c:forEach items="${pb.beanlist}" var="student">
<tr>
<td><h3>${student.username }</h3></td>
<td><h3>${student.password }</h3></td>
<td><h3>${student.sex }</h3></td>
<td><h3>${student.grade }</h3></td>
<td><h3>${student.tel }</h3></td>
</tr>
</c:forEach>
</table>
</center>
<br><br><br><br>
<center> <%@ include file="/page.jsp"%></center>
</body>
</html>
添加页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'tianjia.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="180.jpg">
<form action="tianjia" method="post">
<center style="font-size:50px;padding-right:400px"><span style='color:green'>添加页面</span></center><br><br><br>
<center style="font-size:30px;padding-right:400px"> 用户名:<input type="text" name="username"><br><br><br>
密码:<input type="password" name="password"><br><br><br>
性别:<input type="text" name="sex"><br><br><br>
成绩:<input type="text" name="grade"><br><br><br>
电话:<input type="text" name="tel"><br><br><br>
<input type="submit" value="提交">
<input type="reset" value="重置">
<a href="javascript:history.go(-1)">返回</a>
</center>
</form>
</body>
</html>
更新页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'update.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="e.jpg">
<form action="update" method="post">
<center style="font-size:60px;padding-left:230px;"><span style='color:black'>更新页面</span></center><br>
<center style="font-size:20px;padding-left:250px">用户名:<input type="text" name="username" style="height: 32px; width: 156px; "><br><br>
<center style="font-size:25px;padding-left:20px">密码: <input type="password" name="password" style="height: 29px; width: 156px; "><br><br>
<center style="font-size:25px;">性别:<input type="text" name="sex"><br><br>
<center style="font-size:25px;">成绩:<input type="text" name="grade"><br><br> <td>
<center style="font-size:25px;"> 电话:<input type="text" name="tel"><br><br>
<input type="submit" value="提交">
<input type="reset" value="重置">
<a href="javascript:history.go(-1)">返回</a>
</center>
</form>
</body>
</html>
修改页面
chaxun<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'xiugai.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="s.jpg" >
<form action="update" method="post">
<center style="font-size:50px;padding-top:90px;"><span style='color:purple'>修改页面</span></center><br><br><br>
<center> <center style="font-size:30px;padding-top:20px;">
用户名:<input type="text" name="username" style="height: 34px; width: 152px; "><br><br><br>
密码 <input type="password" name="password"><br><br><br>
性别<input type="text" name="sex"><br><br><br>
成绩<input type="text" name="grade"><br><br><br>
电话<input type="text" name="tel"><br><br><br>
</center>
<input type="submit" value="提交">
<input type="reset" value="重置">
<a href="javascript:history.go(-1)">返回</a>
</form>
</body>
</html>
注册页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'zhuce.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body background="s.jpg">
<form action="addm" method="post">
<center style="padding-left:300px;font-size:30px;padding-top:70px"><h1>注册页面</h1></center>
<center style="font-size:40px;padding-left:250px;padding-top:120px" >新用户:<input type="text" name="username"></center>
<center style="font-size:40px;padding-left:250px;padding-top:100px" >密码:<input type="password" name="password" style="height: 31px; width: 159px; "></center>
<center style="font-size:30px;padding-left:250px;padding-top:130px" >
<input type="submit" value="提交"> <input type="reset" value="重置">
<a href="index.jsp">返回</a>
</form>
</center>
</body>
</html>