1、Web课程设计docWeb课程设计课程设计报告书 设计题目 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)完整实现设计内容所指定的功能(2)应用服务器采用Tomcat 6.0或以上(3)基于JSP编程(4)开发工具采
3、用Eclipse + DreamWeaver(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=; boolean success=false; public void setLog
4、name(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; public void setSuccess(boolean b) success
5、=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(String t) title=t; public String getTitle
6、() 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.javapackage mybean.data;publ
7、icclass 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) password=pw; public String get
8、Password() 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; ConditionQuery.javapackage
9、 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(String s) logname
10、=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 StringBuffer f(String
11、 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(); str.append(+log
12、name); 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) System.out.prin
13、tln(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.init(config); try
14、 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 ServletException,IOException Co
15、nnection 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=new Login(); ses
16、sion.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() backNews=lognam
17、e+你已经登录了; 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.setString(1,logname); sq
18、l.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.setSuccess(false); loginB
19、ean.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.setBackNews(backNews);
20、 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); HandleLogin.java
21、package 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.jdbc.odbc.JdbcOdb
22、cDriver); 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; PreparedStatement sql;
23、 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(login,loginBean);
24、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.setBackNews(back
25、News); 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); ResultSet rs
26、=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); loginBean.setP
27、assword(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(false); RequestDis
28、patcher 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.control;import mybean.data.*;import java.util.Date;import java.text.SimpleDateFormat;import java.sql.*;import java.io.*;i
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1