1013day-人口普查系统
1、shuchu.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.edu.ia.DBUtil" %>
<%@page import = "java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String sql="select * from test";
Connection conn= DBUtil.getConnection();
PreparedStatement papre=conn.prepareStatement(sql);
ResultSet rs=papre.executeQuery();
String n=request.getParameter("name");
String s=request.getParameter("sex");
String i=request.getParameter("nation");
String e=request.getParameter("educator");
boolean p=true;
if(n!=null){
while(rs.next()){
if(n.equals(rs.getString("name"))){
out.println(rs.getString("hubie")+"   "+rs.getString("zhufang")+"   "+rs.getString("mianji")+"   "+rs.getString("fangjianshu")+"   "+rs.getString("name")+"   "+rs.getString("ID")+"   "+rs.getString("sex")+"   "+rs.getString("nation")+"   "+rs.getString("educator")+"   ");
out.print("<br />");
p=false;
}
}
}
else if(s!=null){
while(rs.next()){
if(s.equals(rs.getString("sex"))){
out.println(rs.getString("hubie")+"   "+rs.getString("zhufang")+"   "+rs.getString("mianji")+"   "+rs.getString("fangjianshu")+"   "+rs.getString("name")+"   "+rs.getString("ID")+"   "+rs.getString("sex")+"   "+rs.getString("nation")+"   "+rs.getString("educator")+"   ");
out.print("<br />");
p=false;
}
}
}
else if(i!=null){
while(rs.next()){
if(i.equals(rs.getString("nation"))){
out.println(rs.getString("hubie")+"   "+rs.getString("zhufang")+"   "+rs.getString("mianji")+"   "+rs.getString("fangjianshu")+"   "+rs.getString("name")+"   "+rs.getString("ID")+"   "+rs.getString("sex")+"   "+rs.getString("nation")+"   "+rs.getString("educator")+"   ");
out.print("<br />");
p=false;
}
}
}
else if(e!=null){
while(rs.next()){
if(e.equals(rs.getString("educator"))){
out.println(rs.getString("hubie")+"   "+rs.getString("zhufang")+"   "+rs.getString("mianji")+"   "+rs.getString("fangjianshu")+"   "+rs.getString("name")+"   "+rs.getString("ID")+"   "+rs.getString("sex")+"   "+rs.getString("nation")+"   "+rs.getString("educator")+"   ");
out.print("<br />");
p=false;
}
}
}
%>
<% if(p){
%>
<jsp:forward page = "ErrorPage.jsp"></jsp:forward>
<%
}
%>
<form action="select.jsp" method="get">
<input type="submit" value="返回">
</form>
</body>
</html>
2、update.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.edu.ia.DBUtil" %>
<%@page import = "java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String sql="select * from test";
Connection conn= DBUtil.getConnection();
PreparedStatement papre=conn.prepareStatement(sql);
ResultSet rs=papre.executeQuery();
String n=request.getParameter("name");
boolean s=true;
session.setAttribute("name",n);
while(rs.next()){
if(n.equals(rs.getString("name"))){
out.println(rs.getString("hubie")+"   "+rs.getString("zhufang")+"   "+rs.getString("mianji")+"   "+rs.getString("fangjianshu")+"   "+rs.getString("name")+"   "+rs.getString("ID")+"   "+rs.getString("sex")+"   "+rs.getString("nation")+"   "+rs.getString("educator")+"   ");
out.print("<br />");
s=false;
}
}
%>
<% if(s){
%>
<jsp:forward page = "ErrorPage.jsp"></jsp:forward>
<%
}
%>
<form action="xiugai" method="get">
<table>
<tr>
<td>身份证号码</td>
<td>
<input type="text" name="ID" pattern="[0-9]{5}" title="只能输入数字或最后一位为X">
</td>
</tr>
<tr>
<td>性别</td>
<td>
<input type="radio" name="sex" value="男">男
<input type="radio" name="sex" value="女">女
</td>
</tr>
<tr>
<td>民族</td>
<td>
<input type="text" name="nation">
</td>
</tr>
<tr>
<td>受教育程度</td>
<td>
<input type="text" name="educator" list="elist">
<datalist id="elist">
<option>研究生</option>
<option>大学本科</option>
<option>大学专科</option>
<option>高中</option>
<option>初中</option>
<option>小学</option>
<option>未上过学</option>
</datalist>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="提交">
</td>
<td colspan="2">
<input type="submit" value="返回" formaction="select.jsp">
</td>
</tr>
</table>
</form>
</body>
</html>