基于JSP论坛课程设计报告_第1页
基于JSP论坛课程设计报告_第2页
基于JSP论坛课程设计报告_第3页
基于JSP论坛课程设计报告_第4页
基于JSP论坛课程设计报告_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、jsp课程设计报告bbs论坛设计一、 bbs论坛bbs的英文全称是bulletin board system,译为“电子公告板”。bbs最早是用来公布股市价格等类信息的,一直到互联网与个人计算机普及后广泛流行于网络。目前,通过bbs系统开发出各种论坛、网上社区、交友中心等信息平台。二、 bbs系统角色本系统实现bbs论坛的浏览、发贴、注册等功能。系统的角色分为:1、 普通用户(游客)浏览信息(主贴及加回帖)、用户注册2、 注册用户用户登录、发表主贴、对相关的主贴发表回帖、个人信息维护3、 版主对所属版块信息的维护,对不合适的主贴及回帖维护4、 系统管理员对版块进行管理,对用户进行管理三、 设计

2、基本思路(修改相应的名称与本人项目对应,也可自己设计类似的图)bbs.jsp论坛主页面topiclis.jsp显主题帖、发帖页面发帖replylist.jsp显主题帖、发帖页面发帖gettopicservlet获取相应板块主帖getreplyservlet获取相应板块主帖addtopicservlet获取相应板块主帖addreplyservlet获取相应板块主帖发主题帖查看回帖发回帖delreplyservlet删除回帖删除回帖deltopicservlet删除主帖删除主题帖四、 bbs详细设计分析(给出各页面的运行效果截图、相关的servlet代码,servlet关键加注释)1:背景加的是浮

3、动框架代码:<html><head><title>未标题-2</title><meta http-equiv="content-type" content="text/html; charset=gb2312"></head><body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="

4、0"><!- save for web slices (未标题-2) -><table id="_01" width="1247" height="567" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="3"><img src="images/jing_01.jpg" width="1

5、247" height="50" alt=""></td></tr><tr><td width="90"><img src="images/jing_02.jpg" width="63" height="465" alt=""></td> <td width="1091"><iframe name="left"

6、width="100%" height="80%" scrolling="yes" src="login.jsp" frameborder="0"></iframe></td><td width="66"><img src="images/jing_04.jpg" width="63" height="465" alt=""></td&g

7、t;</tr><tr><td colspan="3"><img src="images/jing_05.jpg" width="1247" height="52" alt=""></td></tr></table><!- end save for web slices -></body></html>1、 系统主页面bbs.jsp运行截图:() 相关代码:导入标签:<%

8、taglib uri=" prefix="c" %><body> <p><br> <img src="images/logo.jpg" width="290" height="70"> <% string uname=(string)session.getattribute("uname"); %> <% if(uname=null) %> <div>你尚未登录 | <a href=&quo

9、t;login.jsp">登录</a> | 注册</div> <% else %> <div>当前用户:<%=uname %></div> <p><% %> <p><a href="gettopicservlet?currentpage=1&boardid=$boardid">首页</a> </p> <table width="928" height="83" b

10、order="1" align="left" cellpadding="0" cellspacing="0"> <%arraylist<board> bdata=boarddao.getallboard(); for(int i=0;i<bdata.size();i+)board tem=bdata.get(i);%> <tr> <th width="134" bgcolor="#00bc9a" scope="c

11、ol"><div align="center"><img src="images/icon3.gif" width="18" height="16"></div></th> <th width="632" bgcolor="#00bc9a" scope="col"><div align="center"><a href="gettop

12、icservlet?boardid=<%=tem.getbid() %>"><%=tem.getbname() %></a></div></th> <th width="105" bgcolor="#00bc9a" scope="col"><div align="center">主贴数:<%=tem.gettopicnum() %></div></th> <th width=

13、"47" bgcolor="#00bc9a" scope="col"><div align="center"></div></th> </tr> <tr> <td bgcolor="#00bc9a"><div align="center"></div></td> <td><div align="center">版主: &

14、lt;% arraylist<user> udata=tem.getbuserdata(); for(int j=0;j<udata.size();j+) out.print(udata.get(j).getuname()+" "); %> </div></td> <td><div align="center"></div></td> <td><div align="center"></div></

15、td> </tr><% %> </table> <p>&nbsp; </p> </body></html>gettopicservlet:/1 获取版块的idstring boardid=request.getparameter("boardid");system.out.print("bid="+boardid);string curnum=request.getparameter("currentpage");if(curnum=nu

16、ll)curnum="1"/2 调用相关的类查询相关的信息getpage mypage=new getpage();dbconnect mydb=new dbconnect();string sql="select * from topic where boardid="+boardid;mypage.setdb(mydb);mypage.setkeyfielsname("topicid");mypage.setp_curpage(integer.parseint(curnum);mypage.setpagesize(3);mypag

17、e.setsql(sql);arraylist<topic> tdata=new arraylist<topic>();resultset re=null;try re=mypage.getpage();while(re.next()topic tem=new topic();tem.settopicid(re.getstring(1);tem.settitle(re.getstring(2);tem.settdata(re.getstring(4);tem.setreplynum(replaydao.getreplaybytopicid(tem.gettopicid(

18、)+"");string userid=re.getstring(5);tem.settopicuser(userdao.getuserinfobyuserid(userid);tdata.add(tem);catch (exception e) e.printstacktrace();/判断是否为版主httpsession session=request.getsession();string u=(string)session.getattribute("uid");system.out.print("u="+u+"aa

19、");boolean flag=false;if(u!=null)/u不为空说明登陆用户,判断是否为版主flag=masterdao.checkmaster(u, boardid);/3 将查询结果送到信息显示request.setattribute("flag", flag);system.out.print("dd="+tdata.size();request.setattribute("ttdata", tdata);request.setattribute("boardid", boardid);

20、request.setattribute("curpage", mypage.getp_curpage();request.setattribute("totalpage", mypage.gettotalpage();request.getrequestdispatcher("topiclist.jsp").forward(request, response); 2、 主题帖显示及发帖页面topiclist.jsp相关代码: 导入标签:<% taglib uri=" prefix="c" %>

21、;<body> <img src="images/logo.jpg" width="290" height="70"> <% string uname=(string)session.getattribute("uname"); %> <% if(uname=null) %> <div>你尚未登录 | <a href="login.jsp">登录</a> | 注册</div> <% else %

22、> <div>当前用户:<%=uname %></div> <p><% %> <p>首页</p> <table width="1018" height="133" border="1" cellpadding="0" cellspacing="0"> <tr> <th width="92" bgcolor="#00bc9a" scope=

23、"col"><div align="center">*</div></th> <th width="521" bgcolor="#00bc9a" scope="col"><div align="center">主帖标题</div></th> <th width="124" bgcolor="#00bc9a" scope="col&q

24、uot;><div align="center">发帖人</div></th> <th width="67" bgcolor="#00bc9a" scope="col"><div align="center">回帖数</div></th> <th width="202" bgcolor="#00bc9a" scope="col"><

25、;div align="center">发帖时间</div></th> </tr> <c:foreach items="$requestscope.ttdata" var="tem"> <tr> <td align="center"> <c:if test="$flag='true'"> <a href="deltopicservlet?topicid=$tem.topici

26、d&&boardid=$param.boardid ">删除</a> </c:if> <c:if test="$flag!='true'"> <img src="images/headimage4.jpg" width="17" height="17"> </c:if></td> <td><a href="neirong?topicid=$tem.topicid&quo

27、t;>$tem.title </a></td> <td align="center">$tem.topicuser.uname</td> <td align="center">$tem.replynum </td> <td align="center">$tem.tdata </td> </tr> </c:foreach> </table> <p align="center"

28、;>共$totalpage 页 当前第$curpage 页 <a href="gettopicservlet?currentpage=1&boardid=$boardid">首页</a> <a href="gettopicservlet?currentpage=$requestscope.curpage-1&boardid=$boardid">上一页</a> <a href="gettopicservlet?currentpage=$requestscope.curpa

29、ge+1&boardid=$boardid">下一页</a> <a href="gettopicservlet?currentpage=$totalpage&boardid=$boardid"> 尾页</a></p></body></html>deltopicservlet:string topicid=request.getparameter("topicid");string boardid=request.getparameter("b

30、oardid");system.out.print(topicid+boardid);int n=topicdao.deltopicbytopicid(topicid);if(n>0)request.getrequestdispatcher("gettopicservlet?boardid="+boardid).forward(request, response);elsesystem.out.print("删除失败");3、 回帖查看及发回帖页面replylist.jsp相关代码:导入标签:<% taglib uri="

31、 prefix="c" %> </head> <script language="javascript"> function check() var a=document.form1.flag.value;if(a="")alert("要发贴,请先登录");return false;var b=document.form1.contentinfo.value;if(content="")alert("请输入主帖的标题");return false

32、;return true; </script> <body> <table width="1039" height="167" border="1" cellpadding="0" cellspacing="0"> <tr> <th width="257" bgcolor="#00bc9a" scope="col"><div align="center"

33、;>发帖人:$topicinfo.topicuser </div></th> <th width="501" bgcolor="#00bc9a" scope="col">主帖标题:$topicinfo.title </th> <th width="148" bgcolor="#00bc9a" scope="col">发帖时间:$topicinfo.tdata </th> <th width=&

34、quot;123" bgcolor="#00bc9a" scope="col">&nbsp;</th> </tr> <tr> <td height="48"><p align="center" class="style1 style1"><img src="images/16.gif" width="14" height="14"></

35、p> <p align="center" class="style1 style1">$topicinfo.topicuser.uname </p></td> <td colspan="3"align="left" valign="top"><p class="style1 style1">内容:</p> <p class="style1 style1">$topic

36、info.tcontent </p></td> </tr> <c:foreach items="$rdata" var="tem" varstatus="i"> <tr> <td height="28" bgcolor="#00bc9a" class="a"><div align="center" class="style1">回帖人</div&g

37、t;</td> <td bgcolor="#00bc9a" class="a">回帖时间:$tem.creatdate </td> <td bgcolor="#00bc9a" class="a">楼层: <c:if test="$i.count=1 ">沙发</c:if> <c:if test="$i.count!=1 ">$i.count </c:if></td> &

38、lt;td bgcolor="#00bc9a" class="a"><a href="delreplyservlet?replyid=$tem.replyid&&topicid=$tem.topicid">删除</a></td> </tr> <tr> <td height="48"><div align="center" class="style1"> <p>

39、<img src="images/6.gif" width="14" height="14"></p> <p>$tem.replyuser.uname</p> </div></td> <td colspan="3" align="left" valign="top"><span class="style1"> <c:if test="$tem.r

40、status=0"> 该帖子已被删除</c:if> <c:if test="$tem.rstatus=1"> $tem.contentinfo </c:if> </span></td> </tr> </c:foreach> </table> <form name="form1" method="post" action="addreplyservlet"> <table width=&q

41、uot;315" height="125" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <th colspan="2" bgcolor="#00bc9a" scope="col">跟帖(提示:请登录)</th> </tr> <tr> <td bgcolor="#0

42、0bc9a">内容</td> <td><label> <textarea name="contentinfo" cols="30" rows="8"></textarea> <input type="hidden" name="flag" value="$sessionscope.userinfo"> <input type="hidden" name="

43、;topicid" value="$param.topicid"> </label></td> </tr> <tr> <td height="23" colspan="2" align="center" bgcolor="#00bc9a"><label> <input type="submit" name="submit" value="提交"

44、> <input type="reset" name="submit2" value="重置"> </label></td> </tr> </table> </form> </body> addreplyservlet:request.setcharacterencoding("gb2312");string content=request.getparameter("contentinfo");strin

45、g topicid=request.getparameter("topicid");system.out.print(content+"|"+topicid+"|");httpsession session=request.getsession();string userid=(string)session.getattribute("uid");int n=replaydao.addreply(content, topicid, userid);/3转向if(n>0)/合法用户 response.sendr

46、edirect("neirong?topicid="+topicid);else/非法用户response.sendredirect("添加失败!");回帖:<% taglib uri=" prefix="c" %> </head> <script language="javascript"> function check() var a=document.form1.flag.value;if(a="")alert("要发贴,请先登录&q

47、uot;);return false;var b=document.form1.contentinfo.value;if(content="")alert("请输入主帖的标题");return false;return true; </script> <body> <table width="1039" height="167" border="1" cellpadding="0" cellspacing="0"> &l

48、t;tr> <th width="257" bgcolor="#00bc9a" scope="col"><div align="center">发帖人:$topicinfo.topicuser </div></th> <th width="501" bgcolor="#00bc9a" scope="col">主帖标题:$topicinfo.title </th> <th w

49、idth="148" bgcolor="#00bc9a" scope="col">发帖时间:$topicinfo.tdata </th> <th width="123" bgcolor="#00bc9a" scope="col">&nbsp;</th> </tr> <tr> <td height="48"><p align="center" cl

50、ass="style1 style1"><img src="images/16.gif" width="14" height="14"></p> <p align="center" class="style1 style1">$topicinfo.topicuser.uname </p></td> <td colspan="3"align="left" valign

51、="top"><p class="style1 style1">内容:</p> <p class="style1 style1">$topicinfo.tcontent </p></td> </tr> <c:foreach items="$rdata" var="tem" varstatus="i"> <tr> <td height="28" bgc

52、olor="#00bc9a" class="a"><div align="center" class="style1">回帖人</div></td> <td bgcolor="#00bc9a" class="a">回帖时间:$tem.creatdate </td> <td bgcolor="#00bc9a" class="a">楼层: <c:if tes

53、t="$i.count=1 ">沙发</c:if> <c:if test="$i.count!=1 ">$i.count </c:if></td> <td bgcolor="#00bc9a" class="a"><a href="delreplyservlet?replyid=$tem.replyid&&topicid=$tem.topicid">删除</a></td> <

54、/tr> <tr> <td height="48"><div align="center" class="style1"> <p><img src="images/6.gif" width="14" height="14"></p> <p>$tem.replyuser.uname</p> </div></td> <td colspan="

55、;3" align="left" valign="top"><span class="style1"> <c:if test="$tem.rstatus=0"> 该帖子已被删除</c:if> <c:if test="$tem.rstatus=1"> $tem.contentinfo </c:if> </span></td> </tr> </c:foreach> </t

56、able> <form name="form1" method="post" action="addreplyservlet"> <table width="315" height="125" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <th colspan="2"

57、 bgcolor="#00bc9a" scope="col">跟帖(提示:请登录)</th> </tr> <tr> <td bgcolor="#00bc9a">内容</td> <td><label> <textarea name="contentinfo" cols="30" rows="8"></textarea> <input type="hi

58、dden" name="flag" value="$sessionscope.userinfo"> <input type="hidden" name="topicid" value="$param.topicid"> </label></td> </tr> <tr> <td height="23" colspan="2" align="center" b

59、gcolor="#00bc9a"><label> <input type="submit" name="submit" value="提交"> <input type="reset" name="submit2" value="重置"> </label></td> </tr> </table> </form> </body> addreplys

60、ervletrequest.setcharacterencoding("gb2312");string content=request.getparameter("contentinfo");string topicid=request.getparameter("topicid");system.out.print(content+"|"+topicid+"|");httpsession session=request.getsession();string userid=(string)se

61、ssion.getattribute("uid");int n=replaydao.addreply(content, topicid, userid);/3转向if(n>0)/合法用户 response.sendredirect("neirong?topicid="+topicid);else/非法用户response.sendredirect("添加失败!");4、 用户登录5、 <body> <div align="center"><img src="images

62、/logo.jpg" width="290" height="70"><br> <% string uname=(string)session.getattribute("uname"); %> <% if(uname=null) %> </div> <div> <div align="center">你尚未登录 | <a href="login.jsp">登录</a> | 注册<

63、;/div> </div> <div align="center"> <% else %> </div> <div> <div align="center">当前用户:<%=uname %></div> </div> <p align="center"> <% %> <form name="form1" method="post" action=&quo

64、t;logincheck"> <table width="334" height="143" border="1" align="center"> <tr> <td width="108" bgcolor="#00bc9a"><div align="center">用户名</div></td> <td width="210"><di

65、v align="center"> <label> <input type="text" name="username"> </label> </div></td> </tr> <tr> <td bgcolor="#00bc9a"><div align="center">密 码</div></td> <td><div align="

66、center"> <label> <input type="password" name="userpass"> </label> </div></td> </tr> <tr> <td colspan="2" bgcolor="#00bc9a"><div align="center"> <label> <input type="submit&qu

67、ot; name="submit" value="提交"> </label> <label> <input type="reset" name="submit2" value="重置"> </label> </div> <div align="center"></div></td> </tr> </table> </form> </b

68、ody></html>logincheck:/1获取request.setcharacterencoding("gb2312");string uname=request.getparameter("username");string upass=request.getparameter("userpass");/2判断string userid=userdao.checkuser(uname, upass);system.out.print("check="+userid+uname+upass

69、);/3转向if(userid!=null)/合法用户 httpsession session=request.getsession();session.setattribute("uid", userid);session.setattribute("uname", uname);response.sendredirect("bbs.jsp");else/非法用户response.sendredirect("login.jsp");6、7、 用户注册<% taglib uri=" prefix=&

70、quot;c" %><body> <p align="center"><img src="images/logo.jpg" width="290" height="70"></p> <p><br> </p> <form name="form1" method="post" action="adduser"> <table width=&qu

71、ot;338" height="209" border="1" align="center" cellpadding="1" cellspacing="1"> <tr> <td width="92" align="center" bgcolor="#00bc9a">用户名</td> <td width="291" align="center"

72、;><label for="textfield"></label> <input type="text" name="username" id="textfield"></td> </tr> <tr> <td align="center" bgcolor="#00bc9a">密码</td> <td align="center"><labe

73、l for="textfield2"></label> <input type="password" name="password" id="textfield2"></td> </tr> <tr> <td align="center" bgcolor="#00bc9a">确认密码</td> <td align="center"><label for="textfield3"></label> <input type="password" nam

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论