Web课程设计(29页).doc

上传人:1595****071 文档编号:35429949 上传时间:2022-08-21 格式:DOC 页数:29 大小:234KB
返回 下载 相关 举报
Web课程设计(29页).doc_第1页
第1页 / 共29页
Web课程设计(29页).doc_第2页
第2页 / 共29页
点击查看更多>>
资源描述

《Web课程设计(29页).doc》由会员分享,可在线阅读,更多相关《Web课程设计(29页).doc(29页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、-Web课程设计-第 29 页Web课程设计课程设计报告书 设计题目 micro blog信息系统 专业班级 xxxxx 学号姓名 xxxxxxxxx 指导老师 xxxxxxx设计日期 xxxx 年x月x日 前言Micro blog信息系统主要是一个校园微博系统,在该系统中可以注册、登录,同时还分普通会员登录及管理员登录。通过登录后,可实现发布、查询、删除微博等各项功能。关键字:信息系统 微博 登录系统分析1.设计目的:1综合应用java程序设计、WEB程序设计、数据库应用、计算机网络等知识设计和实现我校Micro Blog信息系统。2通过上述设计和实现,加深对java程序设计、WEB程序设计

2、、数据库应用、计算机网络相关理论的理解,锻炼综合应用所学知识分析问题和解决问题的能力。3培养软件开发的团队协作精神。系统设计1.设计内容:(1)用户注册(2)用户登录(分一般用户和管理员)(3)某用户发布微博信息(4)浏览所有用户的微博信息(5)浏览指定用户的微博信息(6)查询某些用户或(且)某时间段或(且)某论题的微博信息。(7)删除某些用户或(且)某时间段或(且)某论题的微博信息。(8)统计分析某时间段的用户数量,微博数量。(9)发布重大消息或提示信息(7-9基于管理员)2.设计环境:(1)完整实现设计内容所指定的功能(3)基于JSP编程(4)开发工具采用Eclipse + DreamWe

3、aver(5)数据库采用ACCESS 2003(6)用户界面友好3.系统流程图:主界面管理员登录会员注册会员登录输入信息输入密码输入密码注册成功查询微博删除微博微博统计查询微博浏览微博微博发布退出数据库设计在Micro blog信息系统中,共设计3张表。本系统使用Access来创建数据表。数据库的名称为WEB.mdb,三张表分别为admin、message、user。表:admin表:message表:user系统实现代码Login.javapackage mybean.data;public class Login String logname, password, backNews=; b

4、oolean success=false; public void setLogname(String name) logname=name; public String getLogname() return logname; public void setPassword(String pw) password=pw; public String getPassword() return password; public String getBackNews() return backNews; public void setBackNews(String s) backNews=s; p

5、ublic void setSuccess(boolean b) success=b; public boolean getSuccess() return success;Message.javapackage mybean.data;publicclass Message String logname=,message=,time=,title=,backNews; publicvoid setLogname(String name) logname=name;public String getLogname() returnlogname;publicvoid setTitle(Stri

6、ng t) title=t;public String getTitle() returntitle;publicvoid setTime(String t) time=t;public String getTime() returntime;public String getMessage() returnmessage;publicvoid setMessage(String m) message=m;public String getBackNews() returnbackNews;publicvoid setBackNews(String s) backNews=s;Register

7、.javapackage mybean.data;publicclass Register String logname=,password=,qq=,email=, phone=; String backNews; publicvoid setLogname(String name) logname=name;public String getLogname() returnlogname;publicvoid setQq(String q) qq=q;public String getQq() returnqq;publicvoid setPassword(String pw) passw

8、ord=pw;public String getPassword() returnpassword;publicvoid setEmail(String em) email=em;public String getEmail() returnemail;publicvoid setPhone(String ph) phone=ph;public String getPhone() returnphone;public String getBackNews() returnbackNews;publicvoid setBackNews(String s) backNews=s;Condition

9、Query.javapackage mybean.data;import java.sql.*;public class ConditionQuery String logname ; StringBuffer queryResultBylogname; public ConditionQuery() queryResultBylogname=new StringBuffer(); try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(Exception e) public void setlogname(

10、String s) logname=s.trim(); queryResultBylogname=new StringBuffer(); public String getlogname() return logname; public StringBuffer getQueryResultBylogname() String condition=SELECT * FROM message Where logname = +logname+; queryResultBylogname=f(condition); return queryResultBylogname; private Stri

11、ngBuffer f(String condition) StringBuffer str=new StringBuffer(); Connection con; Statement sql; ResultSet rs; try String uri=jdbc:sqlserver:/127.0.0.1:1433;DatabaseName=factory; con=DriverManager.getConnection(jdbc:odbc:4073,); sql=con.createStatement(); rs=sql.executeQuery(condition); str.append()

12、; str.append(+logname); str.append(+title); str.append(+message); str.append(+time); while(rs.next() str.append(); str.append(+rs.getString(1)+); str.append(+rs.getString(2)+); str.append(+rs.getString(3)+); str.append(+rs.getString(4)+); str.append(); str.append(); con.close(); catch(SQLException e

13、) System.out.println(e); return str;HandleAdmin.javapackage myservlet.control;import mybean.data.*;import java.sql.*;import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class HandleAdmin extends HttpServlet public void init(ServletConfig config) throws ServletException super.i

14、nit(config); try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch(Exception e) public String handleString(String s) try byte bb=s.getBytes(iso-8859-1); s=new String(bb); catch(Exception ee) return s; public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletExceptio

15、n,IOException Connection con; PreparedStatement sql; Login loginBean=null; String backNews=; HttpSession session=request.getSession(true); try loginBean=(Login)session.getAttribute(login); if(loginBean=null) loginBean=new Login(); session.setAttribute(login,loginBean); catch(Exception ee) loginBean=

16、new Login(); session.setAttribute(login,loginBean); String logname=request.getParameter(logname).trim(), password=request.getParameter(password).trim(); boolean ok=loginBean.getSuccess(); logname=handleString(logname); password=handleString(password); if(ok=true&logname.equals(loginBean.getLogname()

17、 backNews=logname+你已经登录了; loginBean.setBackNews(backNews); else boolean boo=(logname.length()0)&(password.length()0); try con=DriverManager.getConnection(jdbc:odbc:4073,); String condition=select * from admin where logname =? and password =?; sql=con.prepareStatement(condition); if(boo) sql.setStrin

18、g(1,logname); sql.setString(2,password); ResultSet rs=sql.executeQuery(); boolean m=rs.next(); if(m=true) backNews=管理员登录成功; loginBean.setBackNews(backNews); loginBean.setSuccess(true); loginBean.setLogname(logname); else backNews=您登陆的管理员不存在,或密码不对; loginBean.setBackNews(backNews); loginBean.setSucces

19、s(false); loginBean.setLogname(logname); loginBean.setPassword(password); else backNews=您输入的管理员不存在,或密码不对; loginBean.setBackNews(backNews); loginBean.setSuccess(false); loginBean.setLogname(logname); loginBean.setPassword(password); con.close(); catch(SQLException exp) backNews=+exp; loginBean.setBac

20、kNews(backNews); loginBean.setSuccess(false); RequestDispatcher dispatcher=request.getRequestDispatcher(showAdminMess.jsp); dispatcher.forward(request, response); public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException doPost(request,response);H

21、andleLogin.javapackage myservlet.control;import mybean.data.*;import java.sql.*;import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class HandleLogin extends HttpServlet public void init(ServletConfig config) throws ServletException super.init(config); try Class.forName(sun.jd

22、bc.odbc.JdbcOdbcDriver); catch(Exception e) public String handleString(String s) try byte bb=s.getBytes(iso-8859-1); s=new String(bb); catch(Exception ee) return s; public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException Connection con; Prepare

23、dStatement sql; Login loginBean=null; String backNews=; HttpSession session=request.getSession(true); try loginBean=(Login)session.getAttribute(login); if(loginBean=null) loginBean=new Login(); session.setAttribute(login,loginBean); catch(Exception ee) loginBean=new Login(); session.setAttribute(log

24、in,loginBean); String logname=request.getParameter(logname).trim(), password=request.getParameter(password).trim(); boolean ok=loginBean.getSuccess(); logname=handleString(logname); password=handleString(password); if(ok=true&logname.equals(loginBean.getLogname() backNews=logname+你已经登录了; loginBean.s

25、etBackNews(backNews); else boolean boo=(logname.length()0)&(password.length()0); try con=DriverManager.getConnection(jdbc:odbc:4073,); String condition=select * from user where logname =? and password =?; sql=con.prepareStatement(condition); if(boo) sql.setString(1,logname); sql.setString(2,password

26、); ResultSet rs=sql.executeQuery(); boolean m=rs.next(); if(m=true) backNews=会员登录成功; loginBean.setBackNews(backNews); loginBean.setSuccess(true); loginBean.setLogname(logname); else backNews=您输入的会员不存在,或密码不对; loginBean.setBackNews(backNews); loginBean.setSuccess(false); loginBean.setLogname(logname);

27、 loginBean.setPassword(password); else backNews=您输入的会员不存在,或密码不对; loginBean.setBackNews(backNews); loginBean.setSuccess(false); loginBean.setLogname(logname); loginBean.setPassword(password); con.close(); catch(SQLException exp) backNews=+exp; loginBean.setBackNews(backNews); loginBean.setSuccess(fal

28、se); RequestDispatcher dispatcher=request.getRequestDispatcher(showLoginMess.jsp); dispatcher.forward(request, response); public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException doPost(request,response);HandleMessage.javapackage myservlet.contro

29、l;import mybean.data.*;import java.util.Date;import java.text.SimpleDateFormat;import java.sql.*;import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class HandleMessage extends HttpServlet public void init(ServletConfig config) throws ServletException super.init(config); try C

30、lass.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch(Exception e) public String handleString(String s) try byte bb=s.getBytes(iso-8859-1); s=new String(bb); catch(Exception ee) return s; public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException Http

31、Session session=request.getSession(true); Login login=(Login)session.getAttribute(login); /获取用户登录时的Javabean boolean ok=true; if(login=null) ok=false; response.sendRedirect(login.jsp); /重定向到登录页面 if(ok=true) continueWork(request,response);public void continueWork(HttpServletRequest request,HttpServlet

32、Response response) throws ServletException,IOException HttpSession session=request.getSession(true); Login login=(Login)session.getAttribute(login); Connection con; PreparedStatement sql; String logname=login.getLogname(); Message mess=new Message(); request.setAttribute(message,mess); String messag

33、e=request.getParameter(message); String title=request.getParameter(title); Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);/参数为你需要的时间格式 String time = sdf.format(now); String backNews=; try con=DriverManager.getConnection(jdbc:odbc:4073,); String insertConditio

34、n=INSERT INTO message VALUES (?,?,?,?); sql=con.prepareStatement(insertCondition); sql.setString(1,handleString(logname); sql.setString(2,handleString(title); sql.setString(3,handleString(message); sql.setString(4,handleString(time); int m=sql.executeUpdate(); if(m!=0) backNews=发布微博成功; mess.setBackN

35、ews(backNews); mess.setLogname(logname); mess.setTitle(handleString(title); mess.setMessage(handleString(message); mess.setTime(time); con.close();catch(SQLException exp) backNews=信息有非法字符+exp; mess.setBackNews(backNews); RequestDispatcher dispatcher= request.getRequestDispatcher(showMessage.jsp);/转发

36、dispatcher.forward(request, response);public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException doPost(request,response);HandleRegister.javapackage myservlet.control;import mybean.data.*;import java.sql.*;import java.io.*;import javax.servlet.*;im

37、port javax.servlet.http.*;public class HandleRegister extends HttpServlet public void init(ServletConfig config) throws ServletException super.init(config); try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch(Exception e) public String handleString(String s) try byte bb=s.getBytes(iso-8859-1); s=new String(bb);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 单元课程

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁