【正文】
userPassword)+39。()。ResultSet rs=null。if((age)!=null) age=(age)。String address=。String sex=。 charset=GBK pageEncoding=GBK import=.*%!DOCTYPE html PUBLIC //W3C//DTD HTML Transitional//EN htmlheadmeta equiv=ContentType content=text/html。nbsp。nbsp。nbsp。nbsp。nbsp。 charset=GBK pageEncoding=GBK%!DOCTYPE html PUBLIC //W3C//DTD HTML Transitional//EN htmlheadmeta equiv=ContentType content=text/html。 ()。 } else { ()。 databaseTXB database=new databaseTXB()。 ( BODY)。 PrintWriter out = ()。 (/HTML)。 ( This is )。 out .println(!DOCTYPE HTML PUBLIC \//W3C//DTD HTML Transitional//EN\)。public class servletTXB extends HttpServlet { /** * Constructor of the object. */ public servletTXB() { super()。import 。當(dāng)用戶信息正確時(shí),轉(zhuǎn)到用戶功能頁面,不正確時(shí),重定向回login頁面。nbsp。nbsp。2. 源文件定義(1) 名稱:通訊簿管理系統(tǒng)首頁功能:系統(tǒng)登錄頁面,核對(duì)用戶登錄系統(tǒng)時(shí)的用戶名和密碼!DOCTYPE HTML PUBLIC //W3C//DTD HTML Transitional//ENhtml head title用戶登錄/title meta equiv=keywords content=keyword1,keyword2,keyword3 meta equiv=description content=this is my page meta equiv=contenttype content=text/html。 } catch(SQLException e) { (())。}public static String change(String str)//處理中文轉(zhuǎn)碼{ try { byte[] byteStr=(ISO88591)。 Statement stmt=()。 } catch(SQLException ex) { (())。 return false。 //執(zhí)行該SQL語句,運(yùn)回ResultSet對(duì)象 if(())//分析ResultSet對(duì)象,確定用戶是否存在 { userExist=true。+change(userName)+39。 }}public boolean logInUser(String userName,String userPassword)//用戶登錄{ boolean userExist=false。public class databaseTXB {Connection connect=null。1. 模塊描述負(fù)責(zé)完成與數(shù)據(jù)庫(kù)的連接、訪問、關(guān)閉等操作。其中,top區(qū)域主要負(fù)責(zé)顯示各個(gè)功能頁面的超鏈接,便于用戶隨時(shí)切換;left區(qū)域主要負(fù)責(zé)顯示用戶進(jìn)行當(dāng)前操作時(shí)輸入信息的表單;right區(qū)域主要負(fù)責(zé)顯示每次操作的運(yùn)行結(jié)果。依據(jù)需求分析結(jié)果,通訊簿管理系統(tǒng)可以分為3個(gè)模塊:數(shù)據(jù)庫(kù)訪問模塊、用戶權(quán)限管理模塊、用戶功能模塊,如圖所示:數(shù)據(jù)庫(kù)訪問模塊通訊簿管理系統(tǒng)用戶權(quán)限管理模塊用戶功能模塊(1) 數(shù)據(jù)庫(kù)訪問模塊:數(shù)據(jù)庫(kù)訪問模塊功能樹如圖所示:加載驅(qū)動(dòng)程序創(chuàng)建連接,執(zhí)行查詢語句通訊簿管理系統(tǒng)創(chuàng)建連接,執(zhí)行非查詢語句關(guān)閉連接(2) 用戶權(quán)限管理模塊:提供新用戶注冊(cè)功能、用戶登錄功能和用戶退出功能。2. 總體設(shè)計(jì)在前面對(duì)用戶需求的分析和研究的過程中,對(duì)于本系統(tǒng)中幾個(gè)主要的功能模塊大致有了一個(gè)抽象的認(rèn)識(shí)。(4) 添加功能:用戶可以添加新的用戶操作,添加的用戶信息作為通訊簿中的一個(gè)新的通訊記錄儲(chǔ)存,并且此用戶在今后獨(dú)立登錄系統(tǒng)。用戶登錄后,可以進(jìn)行通訊簿查詢、添加通訊記錄、刪除通訊記錄、修改通訊記錄等操作。課 程 設(shè) 計(jì) 32通訊簿管理系統(tǒng)1需求分析設(shè)計(jì)通訊簿管理系統(tǒng)的主要目的是為了實(shí)現(xiàn)對(duì)用戶通訊信息的管理并提供方便快捷的查詢途徑。本系統(tǒng)是一個(gè)簡(jiǎn)易的通訊簿管理系統(tǒng),系統(tǒng)的主要功能包括:新用戶注冊(cè)功能,用戶登錄功能。(3) 查詢功能:當(dāng)用戶成功登錄系統(tǒng)后,可以按用戶名,對(duì)系統(tǒng)的所有用戶的通訊信息進(jìn)行查詢操作。(7) 退出功能:用戶單擊“退出”超鏈接后可退出系統(tǒng)并重定向到系統(tǒng)登錄頁面,等待用戶下一次登錄。 本系統(tǒng)采用B/S模式,服務(wù)器端使用JSP進(jìn)行動(dòng)態(tài)網(wǎng)頁的開發(fā)。為使用戶在各個(gè)功能頁面方便地跳轉(zhuǎn),并能隨時(shí)查看運(yùn)行結(jié)果,本系統(tǒng)采用了劃分框窗的頁面布局方式,將整個(gè)瀏覽器窗口劃分為3個(gè)區(qū)域。這樣,既可以節(jié)省編碼時(shí)間,也提高了代碼的利用率。import .*。 } catch(ClassNotFoundException e) { (())。 String strSql=select*from userinfo where userName=39。 //建立查找用戶名和密碼的SQL語句 rs=(strSql)。 } catch(SQLException e) { ()。 rs=(sql)。 try { connect=(jdbc:mysql://localhost:3306/db,root,123)。 }return result。 }}public void close()//關(guān)閉連接{ try { ()。1. 模塊描述提供新用戶注冊(cè)功能、登錄功能、退出功能。trtd width=40%用戶名: /td tdinput type=text name=name/tdtrtd width=40%密碼:/td tdinput type=password name=password/tdtr td colspan=2 align=center input type=submit value=登錄amp。amp。 input type=reset value=清空 /td/table/forma href=新用戶注冊(cè)/a/center/body/html(2) 名稱:處理登錄信息的servlet功能:,核對(duì)用戶登錄信息。import 。import 。 PrintWriter out = ()。 ( BODY)。 ( /BODY)。 } /** * The doPost method of the servlet. br * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOExc