1. 程式人生 > >JSP牛刀小試:學生資訊管理系統

JSP牛刀小試:學生資訊管理系統

    小弟這學期的JSP課程上完了,課程作業是學生資訊管理系統,在開發過程遇到了許多問題,記錄下來,作為自己學習的總結,也可以給大家作為參考。如果有錯誤的地方,多多包涵。

github地址如下:

https://github.com/XiaoZhong233/StudentManagerSystem-JSP-

    一、新建JAVA專案

            File->New->DynamicWebProject

            然後就是配置伺服器,我用的是Tomcat,配置很簡單,到官網下載好之後在專案新建中新增進去就可以了

            

二、引入Mysql的jar包

    因為要用到資料庫和服務端互動,因此要引入mysql的jar包,然後在專案中利用JDBC技術操作資料庫就可以了

    mysql的jar包在官網可以找到,我也上傳到了百度網盤,分享給大家

    https://pan.baidu.com/s/1YfucuLovNKBa4JMci1gfCg

    然後在Java Resources中新建一個lib資料夾,把mysql的jar包貼上到這裡面;

    

    右鍵,如上圖一樣選擇Add to Build Path就可以了,為了保險起見,可以在WebContent的lib檔案中也這樣引入一個sql的jar包。

    三、建立資料庫連線工具

    把專案構建好了,引入了需要用的jar包,我們就可以開始進行開發了。我們與服務端互動,首先就要有個工具,來開啟與資料庫的連線。話不多說,直接上程式碼

package javabean;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class ConnDB {
	private static String URL = "jdbc:mysql://localhost:3306/";	//資料庫連線  "student"是資料庫名
	private static String USER = "root";//資料庫賬號
	private static String PASSWORD = "root";//資料庫密碼
	private  Connection conn = null;
	
	
	/**
	 * 無參建構函式預設的資料庫為student
	 */
	public ConnDB() {
		try {
			URL="jdbc:mysql://localhost:3306/student?characterEncoding=utf-8";
			Class.forName("com.mysql.jdbc.Driver");
			} catch (ClassNotFoundException e) {
			e.printStackTrace();
			}
	}
	
	public ConnDB(String databaseName) {
		try {
		Class.forName("com.mysql.jdbc.Driver");
		URL=URL+databaseName+"?characterEncoding=utf-8";
		} catch (ClassNotFoundException e) {
		e.printStackTrace();
		}
	}
	
	//獲取資料庫連線
	public Connection getConnction() {
	try {
	conn = DriverManager.getConnection(URL, USER, PASSWORD);
	} catch (SQLException e) {
	e.printStackTrace();
	}
	return conn;
	}
	
	
	//關閉資料庫連線
	public void closeCon(Connection con) throws Exception{
	if(con!=null){
	con.close();
	}
	}
	
	 /** 
     * 根據傳入的SQL語句返回一個結果集 
     *  
     * @param sql 
     * @return 
     * @throws Exception 
     */  
	public ResultSet select(String sql) throws Exception {  
        Statement stmt = null;  
        ResultSet rs = null;  
        try {  
            stmt = conn.createStatement();  
            rs = stmt.executeQuery(sql);  
            return rs;  
        } catch (SQLException sqle) {  
            throw new SQLException("select data exception: "  
                    + sqle.getMessage());  
        } catch (Exception e) {  
            throw new Exception("System e exception: " + e.getMessage());  
        }  
  
    }  
  
    /** 
     * 根據傳入的SQL語句向資料庫增加一條記錄 
     *  
     * @param sql 
     * @throws Exception 
     */  
	public void insert(String sql) throws Exception {  
        PreparedStatement ps = null;  
        try {   
             ps = conn.prepareStatement(sql);  
             ps.executeUpdate();   
        } catch (SQLException sqle) {  
            throw new Exception("insert data exception: " + sqle.getMessage());  
        } finally {  
            try {  
                if (ps != null) {  
                    ps.close();  
                }  
            } catch (Exception e) {  
                throw new Exception("ps close exception: " + e.getMessage());  
            }  
        }  
        try {  
            if (conn != null) {  
                conn.close();  
            }  
        } catch (Exception e) {  
            throw new Exception("connection close exception: " + e.getMessage());  
        }  
    }  
  
    /** 
     * 根據傳入的SQL語句更新資料庫記錄 
     *  
     * @param sql 
     * @throws Exception 
     */  
	public void update(String sql) throws Exception {  
        PreparedStatement ps = null;  
        try {  
            ps = conn.prepareStatement(sql);  
            ps.executeUpdate();  
        } catch (SQLException sqle) {  
            throw new Exception("update exception: " + sqle.getMessage());  
        } finally {  
            try {  
                if (ps != null) {  
                    ps.close();  
                }  
            } catch (Exception e) {  
                throw new Exception("ps close exception: " + e.getMessage());  
            }  
        }  
        try {  
            if (conn != null) {  
                conn.close();  
            }  
        } catch (Exception e) {  
            throw new Exception("connection close exception: " + e.getMessage());  
        }  
    }  
  
    /** 
     * 根據傳入的SQL語句刪除一條資料庫記錄 
     *  
     * @param sql 
     * @throws Exception 
     */  
	public void delete(String sql) throws Exception {   
        PreparedStatement ps = null;  
        try {  

            ps = conn.prepareStatement(sql);  
            ps.executeUpdate();  
        } catch (SQLException sqle) {  
            throw new Exception("delete data exception: " + sqle.getMessage());  
        } finally {  
            try {  
                if (ps != null) {  
                    ps.close();  
                }  
            } catch (Exception e) {  
                throw new Exception("ps close exception: " + e.getMessage());  
            }  
        }  
        try {  
            if (conn != null) {  
                conn.close();  
            }  
        } catch (Exception e) {  
            throw new Exception("connection close exception: " + e.getMessage());  
        }  
    }  
	
	
	public static void main(String[] args) {
		ConnDB connDB=new ConnDB();
		try {
			Connection connection=connDB.getConnction();
			System.out.println("連線成功");
			Statement stmt=connection.createStatement();
			ResultSet rs=stmt.executeQuery("select * from studentdata");
			while(rs.next()){
				System.out.println(rs.getString(1));
			}
			connDB.closeCon(connection);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}

這裡資料庫連線的URL為jdbc:mysql://localhost:3306/  其中localhost:3306為使用者名稱和埠,用':'分隔,用navicat連線到sql後就可以檢視(navicat是一個很好用的資料庫視覺化工具,大家可以去官網下載一個來用)

        在navicat中可以看到我們的主機名為localhost,埠號為3306,OK,這就是我們要在jdbc:mysql://後面加的東西。大家可以看到我寫了兩個建構函式,一個無參,預設連線到student這個庫,另一個需要一個String指定資料庫名。

        拿預設連線來說,也就是student這個庫,完整URL為:jdbc:mysql://localhost:3306/student?characterEncoding=utf-8 這裡需要注意的是:如果我用jdbc:mysql://localhost:3306/student也是可以連線的上資料庫的,但是在JDBC寫入資料庫的時候,會出現寫入的值如果是中文,則會在資料庫中亂碼,所以我們可以在jdbc:mysql://localhost:3306/student加上?characterEncoding=utf-8指定我們寫入時候的編碼。

        大家在寫完這個工具的時候可以在main中測試下,是否連線成功

    這樣,我們的資料庫連線工具就寫好了。

    四、接下來就是jsp網頁了

    我先把實現的成果圖貼出來

 

    

 註冊

 

註冊成功

然後資料庫中就會多出註冊的資訊(這裡我新建了一個user表用來記錄使用者名稱和密碼)

 

登陸

 

密碼錯誤或使用者未進行註冊時會提醒,並且重新返回登入介面

 

登入成功後,直接進入學生資訊管理系統介面,這裡可以看到所有學生的資訊(各位同學看到不要打我敲打)

在這個介面,可以對學生資訊進行修改,刪除,查詢操作

 

 

 

新增學生

 

新增成功後:

 

系統會倒數,然後自動跳轉至資訊頁面

 

 

 

刪除學生

在刪除前,系統會彈窗和使用者再一次確認是否刪除資訊,以防誤刪

 

刪除成功後

 

可以看到,剛才新增的記錄已經被刪除了

修改學生

點選修改按鈕,即可進入修改頁面,修改頁面會自動填充好要修改學生的資訊,使用者只需要少許的改動即可修改資訊

 

e.g.把姓名修改成“陳思成已被修改”

 

更改後的學生資訊

 

查詢學生

查詢功能分為按學號查詢,按姓名查詢,按SQL語句查詢

介面做的很簡單,只是用來練習,沒必要花大精力在介面上

 

按學號查詢

 

按姓名查詢

 

按SQL語句查詢

例如,要查詢地信2班的學生的學院,專業,名字資訊,SQL語句如下圖所示

 

查詢結果如下圖所示

系統自動對未加入查詢的屬性列賦null值

 

 

    好了,這就是我們要實現的功能,下面就來看程式碼吧,新建若干個jsp檔案

 

 

    專案程式碼結構:

    

    每個頁面的功能,我已經標註出來了,名字也能看出來哈哈。。

    接下來又是貼程式碼

    

Login_deal.jsp

 

<%@ 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>學生管理系統登入頁</title>
<script language="javascript">
	function check(){
		var username=document.getElementById("username");
		var password=document.getElementById("password");
		if(username.value==""||password.value==""){
			alert("使用者名稱或密碼不可為空!");
			return false;
		}
		return true;

	}
</script>
<script language="javascript">
	function regist(){
		//跳轉至註冊頁
		window.location='register.jsp';
	}
</script>
</head>
<body>
<h1 align='center'>學生資訊管理系統</h1>
<form action="login_deal.jsp">
<div>
<table align='center'>
	<tr>
	<td>使用者名稱:</td>
	<td colspan='2'><input id="username" name="username" type="text" style="width: 90%; "></td>
	</tr>
	<tr>
	<td>密碼:</td>
	<td colspan='2'><input id="password" name="password" type="password" style="width: 90%; "></td>
	</tr>
	<tr>
		<td align='center' style="height: 1; "><input type="reset" value="重置"></td>
		<td align='center' style="height: 1; "><input type="button" value="註冊" onClick="regist()"></td>
		<td align='center' style="width: 1; height: 61px"><input type="submit" value="提交" onClick="return check()"></td>
	</tr>		
	</table>
	</div>
</form>
</body>
</html>

要注意的是,要把開頭三個charset都改成UTF-8,這樣才能在JSP中使用中文

這裡用了一個指令碼來驗證使用者名稱密碼是否非空。

 

Register.jsp(註冊頁面)

 

<%@ 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>註冊管理員</title>
</head>
<body>
<h1 align ="center"> 管理員註冊頁面</h1>
<form action="registerDone.jsp">
<table align="center">
<tr>
<td>使用者名稱:</td>
<td colspan='2'><input id="username" name="username" type="text" style="width: 90%; "></td>
</tr>
<tr>
<td>密碼:</td>
<td colspan='2'><input id="password" name="password" type="password" style="width: 90%; "></td>
</tr>
<tr>
<td align='center' style="height: 1; "><input type="reset" value="重置"></td>
<td align='center' style="height: 1; "><input type="submit" value="註冊"></td>
</tr>
</table>
</form>
</body>
</html>

Register_done.jsp(註冊處理頁面)

 

<%@page import="javabean.ConnDB"%>
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:useBean id="user" class="javabean.User"/>
<jsp:setProperty property="*" name="user"/>
<%request.setCharacterEncoding("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>註冊結果</title>
</head>
<body>
<%
try
{
ConnDB db=new ConnDB();
Connection connection=db.getConnction();
String sql="insert into user values("+user.getUsername()+","+user.getPassword()+")";
db.insert(sql);
out.print("<script>alert('註冊成功'); window.location='login.jsp' </script>");  
}
catch(Exception e){
e.printStackTrace();
out.print("<script>alert('註冊失敗!請重新註冊'); window.location='register.jsp' </script>");  
}
%>

</body>
</html>

Table.css(css檔案,用於控制表格佈局)

@charset "UTF-8";
body{
padding:0px;
margin:0px;
font-size:12px;
}
body a{
color:#03515d;
text-decoration:none;
}
body button{
color:#03515d;
}
body span{
color:#03515d;
}
.center_bottom input{
color:#03515d;
font-size:12px;
height:20px;
width:40px;
padding:2px;
vertical-align:middle;
text-align:center;
margin-bottom:6px;
}
/**************************佈局部分********************/
.table_div{
width:1000px;
padding:10px;
margin:0 auto;
}
.div_clear{
clear:both;
}
.left_top{
background:url("./tab/images/leftbottom.gif");
height:30px;
width:12px;
float:left;
}
.left_center{
background:url("./tab/images/rfcenter.gif");
height:530px;
width:12px;
float:left;
}
.left_bottom{
background:url("./tab/images/leftbottom.gif");
height:35px;
width:12px;
float:left;
}
.center_top{
background:url("./tab/images/center.gif") repeat-x;
height:30px;
line-height:30px;
width:900px;
float:left;
}
.center_center{
height:400px;
width:900px;
float:left;
}
.center_bottom{
background:url("./tab/images/center.gif") repeat-x;
height:35px;
width:900px;
float:left;
line-height:35px;
}
.right_top{
background:url("./tab/images/leftbottom.gif");
height:30px;
width:15px;
float:left;
}
.right_center{
background:url("./tab/images/rfcenter.gif");
height:530px;
width:15px;
float:left;
}
.right_bottom{
background:url("./tab/images/leftbottom.gif");
height:35px;
width:15px;
float:left;
}
/**************************************表格內容***********************************/
.table_content{
margin:5px;
border:1px solid #B5D6E6;
width:890px;
height:520px;
overflow-x:hidden;
overflow-y:auto;
}
.table_content table{
width:100%;
border:0;
border-collapse:collapse;
font-size:12px;
}
.table_content table tr:hover{
background-color:#C1EBFF;
}
.table_content table th{
border-collapse:collapse;
height:22px;
background:url("./tab/images/bg.gif");
border-right:1px solid #B5D6E6;
border-bottom:1px solid #B5D6E6;
}
.table_content table td{
height:22px;
word-wrap:break-word;
max-width:200px;
text-align:center;
vertical-align:middle;
border-right:1px solid #B5D6E6;
border-bottom:1px solid #B5D6E6;
}

 

studentInfo.jsp(學生資訊管理頁)

 

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="javabean.ConnDB"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("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>學生資訊查詢結果</title>
<link type="text/css" rel="stylesheet" href="tablecss.css"/>
</head>
<body>
<%
ConnDB connDB=new ConnDB();
Connection connection=connDB.getConnction();
String sql="select * from studentdata";
ResultSet rs=connDB.select(sql);
%>
<div align="center">
<font size="4"><strong> 學生資訊:</strong><br>  
下面的表格就是查詢結果:
</font><br> 
</div>
<div class="table_div">
<!-- 導航欄部分 -->
<div class="div_clear">
<div class="left_top"></div>
<div class="center_top">
<div style="float:left">
<img src="./tab/images/tb.gif" width="16px" height="16px" style="vertical-align:middle"/>
<span style="font-weight:bold">你當前的位置</span>:[學生資訊管理系統]-[學生資訊表]
</div>
<div style="float:right;padding-right:50px">
<img width='16' height='16' src="./tab/images/query.png" style="vertical-align:middle"/>
<a href="query.jsp"><strong>查詢學生記錄</strong></a> 
</div>

<div style="float:right;padding-right:50px">
<img width='16' height='16' src="./tab/images/add.gif" style="vertical-align:middle"/>
<a href="Insert.jsp"><strong>新增學生記錄</strong></a> 
</div>
</div>
<div class="right_top"></div>
</div>
<!-- 導航欄部分結束 -->
<!-- 表格部分 -->

<div class="div_clear">
<div class="left_center"></div>

<!-- 表格內容塊 -->
<div class="center_center">
<div class="table_content">
<table cellspacing="0px" cellpadding="0px">
<!-- 表頭 -->
<thead>
<tr>
<th width="16%">學院名稱</th>
<th width="16%">專	業</th>
<th width="16%">班	級</th>
<th width="16%">學	號</th>
<th width="16%">姓	名</th>
<th width="20%" style="border-right:none">操作</th>
</tr>
</thead>
<!-- 表體 -->
<tbody>

<%
int count=0;
while(rs.next()){
out.print("<tr>");  
out.print("<td>" + rs.getString(1).toString()+ "</td>");  
out.print("<td>" + rs.getString(2).toString() + "</td>");  
out.print("<td>" + rs.getString(3).toString() + "</td>");  
out.print("<td>" + rs.getString(4).toString() + "</td>");
out.print("<td>" + rs.getString(5).toString() + "</td>");
out.print("<td width='20%' style='border-right:none'><img width='16' height='16' src=\"./tab/images/delete.gif\" ><a href=Delete.jsp?id="+rs.getString(6) + " onclick=\"return window.confirm('是否確定刪除?')\" >刪除</a>"); 
out.print("<img width='16' height='16' src=\"./tab/images/edit.gif\" > <a href=Update.jsp?id="+rs.getString(6) + " onclick=\"return window.confirm('是否確定編輯?')\" >編輯</a></td>"); 
out.print("</tr>");
count++;
}

%>
<!-- 表尾 -->
<tfoot>

</tfoot>
</table>

</div>
</div>

<div class="right_center"></div>
</div>
<!-- 底部框 -->
<div class="div_clear">
<div class="left_bottom"></div>
<div class="center_bottom">
<span>  共有<%=count %>條記錄,當前第 1/1 頁</span>
<div style="float:right;padding-right:30px">
<input type="button" value="首頁"/>
<input type="button" value="上頁"/>
<input type="button" value="下頁"/>
<input type="button" value="尾頁"/>
<span>跳轉到</span>
<input type="text" size="1"/>
<input type="button" value="跳轉"/>
</div>
</div>
<div class="right_bottom"></div>	
</div>
</div>

<%
if (rs != null) {  
rs.close();  
}  	
%>
</body>

這裡就從資料庫讀取資料,然後輸出成表格

Insert.jsp(增加學生記錄頁)

<%@ 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">
<script>
function check(form){
if (form.academy.value == "") {
alert("學院名稱不能為空");
return false;
}
if (form.major.value == "") {
alert("專業不能為空");
return false;
}
if (form.classs.value == "") {
alert("班級不能為空");
return false;
}

if (form.name.value == "") {
alert("姓名不能為空");
return false;
}

//驗證數字的正則表示式 
if (form.sno.value == "") {
alert("學號不能為空");
return false;
}
else
{
var reg=/^\d+$/;
var number=form.sno.value;
if(number.match(reg)){

}
else
{

alert("學號必須為純數字");
return false;
}
}
return true;
}
</script>
<title>新增學生資訊記錄</title>
</head>
<body>
<h1 align="center">新增學生資訊記錄</h1>
<br>
<br>
<form action="insertDeal.jsp" method="post" onsubmit="return check(this)">
<table align="center" border="" cellpadding="10" bordercolor="#89cff0" >
<tr>
<td>學院名稱:</td>
<td><input type="text" name="academy" /></td>
</tr>
<tr>
<td>專  業:</td>
<td><input type="text" name="major" /></td>
</tr>
<tr>
<td>班  級:</td>
<td><input type="text" name="classs" /></td>
</tr>
<tr>
<td>學  號:</td>
<td><input type="text" name="sno"/></td>
</tr>
<tr>
<td>姓  名:</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td align='center' style="height: 1; "><input type="reset" value="重置"></td>
<td colspan="2" align="right"><input type="submit" value="增		加"></td>
</tr>
</table>
</form>
</body>
</html>

 

InsertDeal.jsp(新增學生資訊處理頁)

 

<%@page import="javabean.ConnDB"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("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">
<script type="text/javascript">       
function countDown(secs,surl){           
var jumpTo = document.getElementById('jumpTo');  
jumpTo.innerHTML="<strong>"+secs+"</strong>";    
if(--secs>0){       
setTimeout("countDown("+secs+",'"+surl+"')",1000);       
}       
else{         
location.href=surl;       
-ma  
}       
}       
</script> 
<title>學生資訊新增頁</title>
</head>
<body>
<%
String academy=request.getParameter("academy");
String major=request.getParameter("major");
String classs=request.getParameter("classs");
String sno=request.getParameter("sno");
String name=request.getParameter("name");
try{
ConnDB db=new ConnDB();
db.getConnction();
//String sql="insert into studentdata values('"+academy+"','"+major+"','"+classs+"','"+sno+"','"+name+"')";
String sql=String.format("insert into studentdata (academy,major,class,sno,name)"+
"values('%s','%s','%s','%s','%s')",academy,major,classs,sno,name);
System.out.println(sql);
db.insert(sql);
out.print(" <div center='align' width='100%'><font size='5'><strong> 成功新增學生資訊"+  
"<br><a href='studentInfo.jsp'> <span id='jumpTo'>3</span>秒後系統會自動跳轉,也可點選本處直接跳檢視當前資料庫資料</a> "+ 
"</strong><br> </font></div>");   
String jsscript="<script type='text/javascript'> countDown(3,'studentInfo.jsp'); </script> ";
out.print(jsscript);  
}
catch(Exception e){
e.printStackTrace();
out.print(" <div center='align' width='100%'><font size='5' color='red'><strong> 新增失敗"+  
"<br><a href='Insert.jsp'> <span id='jumpTo'>3</span>秒後系統會自動跳轉,也可點選本處直接跳轉重新新增</a> "+ 
"</strong><br> </font></div>");  
String jsscript="<script type='text/javascript'> countDown(3,'Insert.jsp'); </script> ";
out.print(jsscript); 
}
%>
</body>
</html>

 

Update.jsp(資訊更新頁)

 

<%@page import="java.sql.*"%>
<%@page import="javabean.ConnDB"%>
<%@ 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>
<link type="text/css" rel="stylesheet" href="tablecss.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>更新學生資訊</title>
<script type="text/javascript">
function check(form) {
if (form.academy.value == "") {
alert("學院名稱不能為空");
return false;
}
if (form.major.value == "") {
alert("專業不能為空");
return false;
}
if (form.classs.value == "") {
alert("班級不能為空");
return false;
}
if (form.name.value == "") {
alert("姓名不能為空");
return false;
}

if (form.sno.value == "") {
alert("學號不能為空");
return false;
}
else
{
var reg=/^\d+$/;
var number=form.sno.value;
if(number.match(reg)){

}
else
{
alert("學號必須為純數字");
return false;
}
}
return true;
}
</script>
</head>
<body>
<%
ConnDB db=new ConnDB();
db.getConnction();
String id=request.getParameter("id");
String sql="select * from studentdata where id='"+id+ "'";
ResultSet rs=db.select(sql);
rs.next();
%>
<h1 align="center">修改學生資訊頁</h1>
<form action="updateDeal.jsp" method="post" onsubmit=" return check(this)" >
<div>
<table align="center" border="" cellpadding="10" bordercolor="#89cff0" >
<tr><td>學院名稱:</td>
<td><input type="text" name="academy" value=<%="'"+rs.getString(1)+"'"%>/></td>
</tr>
<tr><td>專  業:</td>
<td><input type="text" name="major" value=<%="'"+rs.getString(2)+"'"%>/></td>
</tr>
<tr><td>班  級:</td>
<td><input type="text" name="classs" value=<%="'"+rs.getString(3)+"'"%>/></td>
</tr>
<tr><td>學  號:</td>
<td><input type="text" name="sno" value=<%="'"+rs.getString(4)+"'"%>/></td>
</tr>
<tr><td>姓  名:</td>
<td><input type="text" name="name" value=<%="'"+rs.getString(5)+"'"%>/></td>
</tr>
<tr><td colspan="2" align="right"><input type="submit" value="修  改"></td></tr>
</table>
<input type="hidden" name="id" value=<%="'"+rs.getString(6)+"'"%>/>
<%
if(rs!=null){
rs.close();
}
%>
</div>
</form>
</body>
</html>

 

UpdateDeal.jsp(資訊更新處理頁)

 

<%@page import="javabean.ConnDB"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("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>更新學生資訊</title>
<script>
function countDown(secs,surl){           
var jumpTo = document.getElementById('jumpTo');  
jumpTo.innerHTML="<strong>"+secs+"</strong>";    
if(--secs>0){       
setTimeout("countDown("+secs+",'"+surl+"')",1000);       
}       
else{         
location.href=surl;       
-ma  
}       
}  
</script>
</head>
<body>
<%
String academy=request.getParameter("academy");
String major=request.getParameter("major");
String classs=request.getParameter("classs");
String sno=request.getParameter("sno");
String name=request.getParameter("name");
int id=Integer.parseInt(request.getParameter("id"));
System.out.println(id);
System.out.println(academy);
System.out.println(major);
System.out.println(classs);
System.out.println(sno);
System.out.println(name);
ConnDB db=new ConnDB();
db.getConnction();
String sql="update studentdata set academy='"+academy+"', major='"+major+"',class='"+classs+"',sno='"+sno+"',name='"+name+"' where id="+id;
try{
db.update(sql);
out.print(" <div center='align' width='100%'><font size='5'><strong> 成功更新學生資訊"+  
"<br><a href='studentInfo.jsp'> <span id='jumpTo'>3</span>秒後系統會自動跳轉,也可點選本處直接跳檢視當前資料庫資料</a> "+ 
"</strong><br> </font></div>");   
String jsscript="<script type='text/javascript'> countDown(3,'studentInfo.jsp'); </script> ";
out.print(jsscript);  
}
catch(Exception e){
e.printStackTrace();
out.print("<script>alert(更新失敗!)</script>");
out.print(" <div center='align' width='100%'><font size='5' color='red'><strong> 更新失敗"+  
"<br><a href='studentInfo.jsp'> <span id='jumpTo'>3</span>秒後系統會自動跳轉,也可點選本處直接跳轉</a> "+ 
"</strong><br> </font></div>");  
String jsscript="<script type='text/javascript'> countDown(3,'studentInfo.jsp'); </script> ";
out.print(jsscript); 
}
%>
<font size="2"><strong> 成功修改資料!  
<a href="studentInfo.jsp">檢視當前資料庫資料</a>  
</strong><br> </font>  
</body>
</html>

 

Delete.jsp(刪除資訊頁面)

 

<%@page import="javabean.ConnDB"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("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>學生資訊刪除頁面</title>
<script>
function countDown(secs,surl){           
var jumpTo = document.getElementById('jumpTo');  
jumpTo.innerHTML="<strong>"+secs+"</strong>";    
if(--secs>0){       
setTimeout("countDown("+secs+",'"+surl+"')",1000);       
}       
else{         
location.href=surl;       
-ma  
}       
}  
</script>
</head>
<body>
<%
try
{
ConnDB db=new ConnDB();
db.getConnction();
String id=request.getParameter("id");
System.out.println(id);
String sql_delete="delete from studentdata where id= '" +id+"'";
db.delete(sql_delete);
out.print(" <div center='align' width='100%'><font size='5'><strong> 成功刪除學生資訊"+  
"<br><a href='studentInfo.jsp'> <span id='jumpTo'>3</span>秒後系統會自動跳轉,也可點選本處直接跳檢視當前資料庫資料</a> "+ 
"</strong><br> </font></div>");   
String jsscript="<script type='text/javascript'> countDown(3,'studentInfo.jsp'); </script> ";
out.print(jsscript);  
}
catch(Exception e){
e.printStackTrace();
out.print("<script>alert(刪除失敗!)</script>");
out.print(" <div center='align' width='100%'><font size='5' color='red'><strong> 新增失敗"+  
"<br><a href='studentInfo.jsp'> <span id='jumpTo'>3</span>秒後系統會自動跳轉,也可點選本處直接跳轉重新刪除</a> "+ 
"</strong><br> </font></div>");  
String jsscript="<script type='text/javascript'> countDown(3,'studentInfo.jsp'); </script> ";
out.print(jsscript); 
}
%>
</body>
</html>

 

Query.jsp(查詢頁面)

 

<%@ 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>選擇查詢方式</title>
<script language='javascript'>
function byxuehao(){
window.location='queryByXueHao.jsp';
}
</script>
<script language='javascript'>
function byxingming(){
window.location='queryByXingMing.jsp';
}
</script>
<script language='javascript'>
function bysql(){
window.location='queryBySQL.jsp';
}
</script>
</head>
<body>
<table align="center" cellpadding="5" cellspacing="5" >
<tr>
<td>
<input type="button" value="按照學號查詢" onClick="byxuehao()" style="width: 165px; ">
</td>
</tr>
<tr>
<td>
<input type="button" value="按照姓名查詢" onClick="byxingming()" style="width: 165px; ">
</td>
</tr>
<tr>
<td>
<input type="button" value="按SQL語句查詢" onClick="bysql()" style="width: 165px; ">
</td>
</tr>
</table>
</body>
</html>

 

queryByXueHao.jsp(按學號查詢頁面)

 

<%@ 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">
<script type="text/javascript">
function check(form) {
if (form.xuehao.value == "") {
alert("學號不能為空");
return false;
}
else
{
var reg=/^\d+$/;
var number=form.xuehao.value;
if(number.match(reg)){

}
else
{
alert("學號必須為純數字");
return false;
}
}
return true;
}
</script>
<title>學生資訊查詢</title>
</head>
<body>
<h1 align="center">
請輸入學號,進行查詢
</h1>
<form action="queryByXueHaoDone.jsp"  onsubmit=" return check(this)">
<table align="center" cellpadding="5" cellspacing="5">
<tr>
<td>學號:</td>
<td colspan='2'><input id="xuehao" name="xuehao" type="text" style="width: 90%; "></td>
</tr>
<tr style="width: 312px; ">
<td align='center' style="height: 1; "></td>
<td align='center' style="height: 1; width: 182px"><input type="reset" value="重置">     
     <input type="submit" value="查詢"></td>
</tr>
</table>
</form>
</body>
</html>

 

QueryByXingMing.jsp(按姓名查詢)

 

<%@ 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>學生資訊查詢</title>
</head>
<body>
<h1 align="center">
請輸入姓名,進行查詢
</h1>
<form action="queryByXingMingDone.jsp" >
<table align="center" cellpadding="5" cellspacing="5">
<tr>
<td>姓名:</td>
<td colspan='2'><input id="name" name="name" type="text" style="width: 90%; "></td>
</tr>
<tr style="width: 312px; ">
<td align='center' style="height: 1; "></td>
<td align='center' style="height: 1; width: 182px"><input type="reset" value="重置">     
     <input type="submit" value="查詢"></td>
</tr>
</table>
</form>
</body>
</html>

 

QueryByXingMingDone.jsp(姓名查詢介面)

 

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="javabean.ConnDB"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("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">
<script>
function countDown(secs,surl){           
var jumpTo = document.getElementById('jumpTo');  
jumpTo.innerHTML="<strong>"+secs+"</strong>";    
if(--secs>0){       
setTimeout("countDown("+secs+",'"+surl+"')",1000);       
}       
else{         
location.href=surl;       
-ma  
}       
}  
</script>
<title>學生資訊查詢結果</title>
<link type="text/css" rel="stylesheet" href="tablecss.css"/>
</head>
<body>
<%
String name=request.getParameter("name");
ConnDB connDB=new ConnDB();
Connection connection=connDB.getConnction();
String sql="select * from studentdata where name='"+name+"'";
ResultSet rs=null;
try{
rs=connDB.select(sql);
}catch(Exception e){
e.printStackTrace();
out.print("<script>alert(\"查詢失敗\")</script>");
out.print("window.location='query.jsp'");
}
%>



<div align="center">
<font size="4"><strong> 學生資訊:</strong><br>  
下面的表格就是查詢結果:
</font><br> 
</div>

<div class="table_div">
<!-- 導航欄部分 -->
<div class="div_clear">
<div class="left_top"></div>
<div class="center_top">
<div style="float:left">
<img src="./tab/images/tb.gif" width="16px" height="16px" style="vertical-align:middle"/>
<span style="font-weight:bold">你當前的位置</span>:<a href='studentInfo.jsp'>[學生資訊管理系統]</a>-<a href='query.jsp'>[學生查詢]</a>-[按姓名語句查詢]
</div>
<div style="float:right;padding-right:50px">
<img width='16' height='16' src="./tab/images/query.png" style="vertical-align:middle"/>
<a href="query.jsp"><strong>查詢學生記錄</strong></a> 
</div>

<div style="float:right;padding-right:50px">
<img width='16' height='16' src="./tab/images/add.gif" style="vertical-align:middle"/>
<a href="Insert.jsp"><strong>新增學生記錄</strong></a> 
</div>
</div>
<div class="right_top"></div>
</div>
<!-- 導航欄部分結束 -->
<!-- 表格部分 -->

<div class="div_clear">
<div class="left_center"></div>

<!-- 表格內容塊 -->
<div class="center_center">
<div class="table_content">
<table cellspacing="0px" cellpadding="0px">
<!-- 表頭 -->
<thead>
<tr>
<th width="16%">學院名稱</th>
<th width="16%">專	業</th>
<th width="16%">班	級</th>
<th width="16%">學	號</th>
<th width="16%">姓	名</th>
<th width="20%" style="border-right:none">操作</th>
</tr>
</thead>
<!-- 表體 -->
<tbody>

<%
int count=0;
if(!rs.next()){
out.print("<tr>");  
out.print("<td colspan=6>");  
out.print(" <div center='align' width='100%'><font size='5' color='red'><strong> 查詢失敗:未查詢到該學生記錄"+  
"<br><a href='query.jsp'> <span id='jumpTo'>8</span>秒後系統會自動跳轉,也可點選本處直接跳轉重新查詢</a> "+ 
"</strong><br> </font></div>");  
String jsscript="<script type='text/javascript'> countDown(8,'query.jsp'); </script> ";
out.print(jsscript);
out.print("</td>");
out.print("</tr>");
}
else{
rs.beforeFirst();
while(rs.next()){
out.print("<tr>");  
out.print("<td>" + rs.getString(1).toString()+ "</td>");  
out.print("<td>" + rs.getString(2).toString() + "</td>");  
out.print("<td>" + rs.getString(3).toString() + "</td>");  
out.print("<td>" + rs.getString(4).toString() + "</td>");
out.print("<td>" + rs.getString(5).toString() + "</td>");
out.print("<td width='20%' style='border-right:none'><img width='16' height='16' src=\"./tab/images/delete.gif\" ><a href=Delete.jsp?id="+rs.getString(6) + " onclick=\"return window.confirm('是否確定刪除?')\" >刪除</a>"); 
out.print("<img width='16' height='16' src=\"./tab/images/edit.gif\" > <a href=Update.jsp?id="+rs.getString(6) + " onclick=\"return window.confirm('是否確定編輯?')\" >編輯</a></td>"); 
out.print("</tr>");
count++;
}
}
%>
<!-- 表尾 -->
<tfoot>

</tfoot>
</table>

</div>
</div>

<div class="right_center"></div>
</div>
<!-- 底部框 -->
<div class="div_clear">
<div class="left_bottom"></div>
<div class="center_bottom">
<span>  共有<%=count %>條記錄,當前第 1/1 頁</span>
<div style="float:right;padding-right:30px">
<input type="button" value="首頁"/>
<input type="button" value="上頁"/>
<input type="button" value="下頁"/>
<input type="button" value="尾頁"/>
<span>跳轉到</span>
<input type="text" size="1"/>
<input type="button" value="跳轉"/>
</div>
</div>
<div class="right_bottom"></div>	
</div>
</div>
<%
if (rs != null) {  
rs.close();  
}  	
%>
</body>
</html>

 

QueryBySQL.jsp(按照SQL語句進行查詢)

 

<%@ 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>學生資訊查詢</title>
<style type='text/css'>
.main{
text-align: center; /*讓div內部文字居中*/
background-color: #fff;
opacity:1;
border-radius: 20px;
width: 50%;
height: 370px;
margin: auto;
position: relative;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: 2px solid black; 
}
</style>
<style type='text/css'>
.leftDiv{
text-align: left; /*讓div內部文字居中*/
width: 100%;
height: 100%;
left:0;
opacity:1;
top:27%;
position: absolute;
float:left;
}
</style>
<script language='javascript'>
function check(form){
var text = document.getElementById('sql').value.length;
if(text==0){
alert("SQL語句不可為空");
return false;
}
return true;
}
</script>
</head>
<body>
<h1 align='center'>使用SQL查詢語句進行查詢</h1>
<div class='main'  >
<br>
<div>
<form action="queryBySQLDone.jsp" onsubmit=" return check(this)" >
<table align="left" cellpadding="5" cellspacing="5">
<tr>
<td colspan='2'>SQL語句: </td>
<td colspan='6'><textarea  name="sql" id='sql' cols="28" rows="5" wrap="virtual"></textarea></td>
<td align='center' style="height: 1; "></td>
<td align='center' style="height: 1; width: 182px"><input type="submit" value="查詢">   
     <input type="reset" value="重置"></td>
</tr>
</table>
</form>
</div>
<br>
<div class='leftDiv' >

<h5 align=center>以下是注意事項</h5>
<p>只支援簡單查詢,例如select [屬性] from [表] where [約束]。不支援連線查詢</p>
<font size='5'  >
<ul>
<li >學生資訊表名稱---><Strong>studentdata</Strong></li>
<li>屬性列:academy--->學院名</li>
<li>屬性列:major--->專業名</li>
<li>屬性列:class--->班級</li>
<li>屬性列:sno--->學號</li>
<li>屬性列:name--->姓名</li>
</ul>
</font>
</div>
</div>
<br>
<br>
</body>
</html>

 

QueryBySQLDone.jsp(按SQL語句查詢結果)

 

<%@page import="java.util.*"%>
<%@page import="java.sql.ResultSetMetaData"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="javabean.ConnDB"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("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">
<script>
function countDown(secs,surl){           
var jumpTo = document.getElementById('jumpTo');  
jumpTo.innerHTML="<strong>"+secs+"</strong>";    
if(--secs>0){       
setTimeout("countDown("+secs+",'"+surl+"')",1000);       
}       
else{         
location.href=surl;       
-ma  
}       
}  
</script>
<title>學生資訊查詢結果</title>
<link type="text/css" rel="stylesheet" href="tablecss.css"/>
</head>
<body>
<%
String sql=request.getParameter("sql");
ConnDB connDB=new ConnDB();
Connection connection=connDB.getConnction();
ResultSet rs=null;
try{
rs=connDB.select(sql);
}catch(Exception e){
e.printStackTrace();
out.print("<script>alert(\"查詢失敗\")</script>");
out.print("window.location='query.jsp'");
}
%>
<div align="center">
<font size="4"><strong> 學生資訊:</strong><br>  
下面的表格就是查詢結果:
</font><br> 
</div>

<div class="table_div">
<!-- 導航欄部分 -->
<div class="div_clear">
<div class="left_top"></div>
<div class="center_top">
<div style="float:left">
<img src="./tab/images/tb.gif" width="16px" height="16px" style="vertical-align:middle"/>
<span style="font-weight:bold">你當前的位置</span>:<a href='studentInfo.jsp'>[學生資訊管理系統]</a>-<a href='query.jsp'>[學生查詢]</a>-[按SQL語句查詢]
</div>
<div style="float:right;padding-right:50px">
<img width='16' height='16' src="./tab/images/query.png" style="vertical-align:middle"/>
<a href="query.jsp"><strong>查詢學生記錄</strong></a> 
</div>

<div style="float:right;padding-right:50px">
<img width='16' height='16' src="./tab/images/add.gif" style="vertical-align:middle"/>
<a href="Insert.jsp"><strong>新增學生記錄</strong></a> 
</div>
</div>
<div class="right_top"></div>
</div>
<!-- 導航欄部分結束 -->
<!-- 表格部分 -->

<div class="div_clear">
<div class="left_center"></div>

<!-- 表格內容塊 -->
<div class="center_center">
<div class="table_content">
<table cellspacing="0px" cellpadding="0px">
<!-- 表頭 -->
<thead>
<tr>
<th width="16%">學院名稱</th>
<th width="16%">專	業</th>
<th width="16%">班	級</th>
<th width="16%">學	號</th>
<th width="16%">姓	名</th>
<th width="20%" style="border-right:none">操作</th>
</tr>
</thead>
<!-- 表體 -->
<tbody>

<%
int count=0;
if(!rs.next()){
out.print("<tr>");  
out.print("<td colspan=6>");  
out.print(" <div center='align' width='100%'><font size='5' color='red'><strong> 查詢失敗:未查詢到該學生記錄"+  
"<br><a href='query.jsp'> <span id='jumpTo'>8</span>秒後系統會自動跳轉,也可點選本處直接跳轉重新查詢</a> "+ 
"</strong><br> </font></div>");  
String jsscript="<script type='text/javascript'> countDown(8,'query.jsp'); </script> ";
out.print(jsscript);
out.print("</td>");
out.print("</tr>");
}
else{
rs.beforeFirst();
//獲取列數
ResultSetMetaData resultSetMetaData=rs.getMetaData();
int numColumn=resultSetMetaData.getColumnCount();
int i;
List<String> name=new ArrayList<String>();
String columnName;
//定義開關,true的位置說明是有資料的
boolean[] switchs=new boolean[]{false,false,false,false,false,false};
for(i=1;i<=numColumn;i++){
columnName=resultSetMetaData.getColumnName(i);
System.out.println(columnName);
switch(columnName){
case "academy":
switchs[0]=true;		
break;
case "major":
switchs[1]=true;		
break;
case "class":
switchs[2]=true;		
break;
case "sno":
switchs[3]=true;		
break;
case "name":
switchs[4]=true;		
break;
case "id":
break;
default:
break;
}
}

//定義rs的列數
int rsColumn;
while(rs.next()){
//i確定位置,rsColumn確定資料在rs中的位置
i=1;
rsColumn=0;
out.print("<tr>");  
for(;i<=6;i++){
if(switchs[i-1]){
if(rsColumn<=numColumn)
{
rsColumn++;
}
out.print("<td>" + rs.getString(rsColumn).toString()+ "</td>");
}
else{
if(i!=6){
out.print("<td>" +"null"+ "</td>");
}
else{
out.print("<td>" +"暫不支援操作"+ "</td>");
}

}

}
out.print("</tr>");
count++;
}
}
%>
<!-- 表尾 -->
<tfoot>

</tfoot>
</table>

</div>
</div>

<div class="right_center"></div>
</div>
<!-- 底部框 -->
<div class="div_clear">
<div class="left_bottom"></div>
<div class="center_bottom">
<span>  共有<%=count %>條記錄,當前第 1/1 頁</span>
<div style="float:right;padding-right:30px">
<input type="button" value="首頁"/>
<input type="button" value="上頁"/>
<input type="button" value="下頁"/>
<input type="button" value="尾頁"/>
<span>跳轉到</span>
<input type="text" size="1"/>
<input type="button" value="跳轉"/>
</div>
</div>
<div class="right_bottom"></div>	
</div>
</div>

<%
if (rs != null) {  
rs.close();  
}  	
%>


</body>
</html>