1、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)完整实现设计内容所指定功效(2)应用服务器采取Tomcat 6.0或以上(3)基于JSP编程(4)开发工具采取Eclipse + DreamWea
3、ver(5)数据库采取ACCESS (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
4、 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; public
5、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(String
6、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; Reg
7、ister.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
8、pw) password=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) back
9、News=s; ConditionQuery.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
10、 void setlogname(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 queryResultBylogn
11、ame; private StringBuffer 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(conditi
12、on); str.append(); 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(); cat
13、ch(SQLException e) 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 Servle
14、tException 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); catch(Exception ee) return s; public void doPost(HttpServletRequest request,HttpServletResponse response) thro
15、ws ServletException,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(Except
16、ion ee) loginBean=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(logi
17、nBean.getLogname() 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
18、(boo) sql.setString(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); lo
19、ginBean.setSuccess(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;
20、loginBean.setBackNews(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(req
21、uest,response); HandleLogin.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 Cla
22、ss.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 Connec
23、tion 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(); session
24、.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=logname+你已
25、经登录了; loginBean.setBackNews(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.set
26、String(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); loginBean.setL
27、ogname(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); loginBean
28、.setSuccess(false); 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
29、myservlet.control;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.ini
30、t(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 ServletException,
31、IOException HttpSession 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 req
32、uest,HttpServletResponse 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
33、); String message=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
34、 insertCondition=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.setBackNews(backNews); mess.setLogname(logname); mess.setTitle(handleString(title); mess.setMessage(handleString(message); mess.setTim