【正文】
名稱 數(shù)據(jù)類型 是否為空 是否主鍵 默認(rèn)值 說明 id int(4) No Yes NULL 自動(dòng)編號(hào) typeName int(4) Yes No NULL 文章類型名稱 description varchar(50) Yes No NULL 文章類型描述 19 表 47 表 tb_discuss 的結(jié)構(gòu) 字段名稱 數(shù)據(jù)類型 是否為空 是否主鍵 默認(rèn)值 說明 id int(4) No Yes NULL 自動(dòng)編號(hào) discussTitle varchar(30) Yes No NULL 討論主題 discussContent varchar(100) Yes No NULL 討論內(nèi)容 discussTime datetime(8) Yes No NULL 討論時(shí)間 表 48 表 tb_friend 的結(jié)構(gòu) 字段名稱 數(shù)據(jù)類型 是否為空 是否主鍵 默認(rèn)值 說明 id int(4) No Yes NULL 自動(dòng)編號(hào) name varchar(50) Yes No NULL 好友昵稱 Number int(4) Yes No NULL 好友 號(hào)碼 description varchar(50) Yes No NULL 對(duì)好友的描述 數(shù)據(jù)連接( JDBCODBC橋) JSP 通過 Java 數(shù)據(jù)庫連接( JDBC)與數(shù)據(jù)庫進(jìn)行交 互。如果登錄的用戶就是博主本人,在博主信息顯示區(qū)域中,則出現(xiàn)“進(jìn)入后臺(tái)”超鏈接,博主可以直接單擊此超鏈接,進(jìn)入博客網(wǎng)的后臺(tái)進(jìn)行管理。相冊(cè)管理模塊的流程如圖 43 所示。用戶登錄功能模塊的 Servlet 實(shí)現(xiàn)類繼承了 HttpServlet 類,在該類中首先設(shè)置用戶登錄模塊的 ConsumerDao 類的對(duì)象,該對(duì)象在每個(gè)具體的方法中實(shí)例化, doGet()在 Servlet 中自動(dòng)被調(diào)用。在用戶登錄頁面中,用戶可以通過輸入正確的用戶名和密碼進(jìn)入到系統(tǒng),當(dāng)用戶沒有輸入用戶名和密碼時(shí),系統(tǒng)會(huì)通過 JavaScript 腳本進(jìn)行判斷,并給予提示信息。驗(yàn)證用戶身份的 checkConsumer()方法的具體代碼如下: public void checkConsumer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { (gb2312)。 (request, response)。 … ((10))。在該頁面中, 29 首先通過 JavaBean 定義分類操作的類( MyPagination),之后調(diào)用 ArticleDao 類中的 queryArticle()方法查詢所有的文章信息,最后將查詢的結(jié)果顯示在頁面中。 order by id desc。 ((6))。 圖 54 前臺(tái)分類顯示文章信息 31 圖 55 文章詳細(xì)查詢頁面 通過 jsp:useBean動(dòng)作標(biāo)簽實(shí)現(xiàn) ArticleDao 類中的 queryArticleForm()方法,該方法主要以文章編號(hào)為條件,執(zhí)行文章查詢的 SQL 語句。 ((4))。 ((2))。 頁將根據(jù)這個(gè) id 值顯示所對(duì)應(yīng)的文章信息。 ((4))。 else sql = select * from tb_article where typeID=39。 jsp:useBean執(zhí)行方式非常靈活,如果執(zhí)行到 jsp:useBean,將去尋找是否存在相同 ID 和 scope。 while (()) { consumerForm = new ConsumerForm()。 } else { (form, consumerForm)。 if (method == 0) { checkConsumer(request, response)。 } 25 … } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response)。 charset=gb2312 language=java import=.* errorPage= % jsp:include page= flush=true / 23 table width=800 border=0 align=center cellpadding=0 cellspacing=0 tr td width=74img src=images/ width=74 height=846/td td height=846 valign=top background=images/ jsp:include page= flush=true / td width=10 background=images/img src=images/ width=13 height=846/td td width=184 valign=top jsp:include page= flush=true / /td td width=122img src=images/ width=122 height=846/td /tr /table jsp:include page= flush=true / 前臺(tái)首頁運(yùn)行結(jié)果如圖 52 所示。前臺(tái)文章查詢模塊的流程如圖 42 所示。博客網(wǎng)運(yùn)行的第一個(gè)頁面便是用戶登錄頁面,用戶登錄后,可以查看博主所發(fā)表的文章。 (8)tb_friend 表主要用來保存朋友信息,如表 48。 (4)tb_restore 表主要用來保存文章回復(fù)信息,如表 44。博客文章信息實(shí)體的 ER 圖如圖 37 所示。 高級(jí)管理員登錄進(jìn)后臺(tái)頁面后,可以對(duì)博客文章、個(gè)人相冊(cè)、好友信息、投票、公告和用戶進(jìn)行管理,也可以修改博主信息。而 Java 定義有完整的安全機(jī)制,包括 SSL\CA認(rèn)證、安全政策等規(guī)范 [1]。 ④ 功能強(qiáng)大 在 Servlet 中,許多使用傳統(tǒng) CGI 程序很難完成的任務(wù)都可以利用 Servlet技術(shù)輕松地完成。 10 第 3 章 需求分析 (1)經(jīng)濟(jì)可行性 博客網(wǎng)通過我的文章和相冊(cè)上傳等功能模塊,吸引更多 的瀏覽者,增加網(wǎng)站的訪問量,提升網(wǎng)站的影響力;不斷更新網(wǎng)站信息內(nèi)容,使網(wǎng)站信息更加多元化,適合不同的訪問群體;通過網(wǎng)站展現(xiàn)個(gè)人魅力,愉悅身心;通過與來訪者的交流,不斷積累經(jīng)驗(yàn),吸收新的知識(shí),使網(wǎng)站適中充滿新鮮活力 [1]。 SQL Server 2020 的特點(diǎn) : (1)真正的客 戶機(jī) /服務(wù)器體系結(jié)構(gòu)。 JavaBean 是一種 JSP 類( Class),通過封裝屬性和方法稱為具有某種功能或者處理某個(gè)業(yè)務(wù)的對(duì)象。 (3)生命周期 Servlet 是運(yùn)行在服務(wù)器端的程序,所以 Servlet 的運(yùn)行狀態(tài)完全由 Servlet 容器維護(hù),一個(gè) Servlet 的生命周期一般有 3 個(gè)過程。 ② 與其它服務(wù)器資源(包括數(shù)據(jù)庫和基于 Java 的應(yīng)用程序)進(jìn)行通信。 JSP 核心技術(shù)簡介 Java Servlet 技術(shù) (1)原理 Servlet 是使用 Java Servlet 應(yīng)用程序設(shè)計(jì)接口( API)及相關(guān)類和方法的 Java程序,其主要優(yōu)點(diǎn)是平臺(tái)獨(dú)立性和安全性。無論 是 愿意享受手工編寫 HTML 代碼時(shí)的駕馭感還是偏愛在可視化編輯環(huán)境中工作, Dreamweaver 都會(huì)提供有用的工具,使 我們 擁有更加完美的 Web 創(chuàng)作體驗(yàn) [7]。因此需要一個(gè)交互式的 Web,于是便誕生了各種 Web 語言。例如美國著名博客網(wǎng)站 “ 德拉吉報(bào)道 ” ,自從克林頓 的性丑聞事件從那里傳出后,德拉吉先生從此名聲大噪,據(jù)說其網(wǎng)站一年的廣告收入達(dá)到 80 萬美元。 博客發(fā)展趨勢 趨勢一:博客現(xiàn)在正在形成個(gè)人的信譽(yù)機(jī)制,有了博客之 后就確立了一個(gè)個(gè)人虛擬身份,簡單的來講就是個(gè)人在互聯(lián)網(wǎng)上是有名有姓的,而不再是一種匿名的行為,網(wǎng)民從流浪漢變成了一個(gè)定居者。 。以“個(gè)人大腦”作為網(wǎng)絡(luò)搜索引擎和思想發(fā)源地,依然是任何技術(shù)無法實(shí)現(xiàn)的極致。也許形式上很接近,但內(nèi)在有著本質(zhì)的差異。 2 不僅如此,寫博客、記錄自己的想法可以幫助 自己 實(shí)現(xiàn)如下這 些目的: (1)記錄生活,在自己的每一天上留下思考的劃痕。博客可以美化一個(gè)人的生活!而所謂的新媒體革命,所謂的人際交往和知識(shí)傳播的革命,都是第二層次的,通過分享,美化每一個(gè)博客,美化每一個(gè)人的生活,自然美化整個(gè)社會(huì)。 關(guān)鍵詞: 博客網(wǎng) ; JSP; Servlet; JavaBean II Abstract In information age, the Inter has bee part of people’s work and study, and constantly enriched and changed people’s life. In recent years, blog site has bee a new platform in public munication after personal page and BBS. Users can express their own thoughts and municate with the blogger joyfully. Besides, JSP and Servlet are two extremely unique dynamic Web technology, which are in many ways even better than CGI and ASP that we already familiar. The bination is the expansion of Java technology on Web server. Therefore the best way to embody advantages of JSP is developing a blog site in JSP + Servlet + JavaBean schema. This system implemented the basic function of blog site, and provided a platform showing themselves online. The system was divided into foreground and background application, which mainly implemented the following goals. By publishing My Article, you can express your thoughts and ideas. By uploading personal photo album, visitors can know more about the blogger. Users have access to viewing articles and publishing opinions. The blogger manages article and photo album information. List of the latest blog is shown for users to browse. Website statistical information is provided for visitors to know about the website. Using Servlet and JavaBean to develop this website showed the design philosophy of MVC, which makes presentation layer, data layer and function layers separated and control the flow of the page by using Servlet. This system used MyEclipse and Macromedia Dreamweaver 8 as dev