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 + DreamWeav
3、er(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 v
5、oid 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 t)
6、 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; Regis
7、ter.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)
8、 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) backNew
9、s=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 vo
10、id 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 queryResultBylogname
11、; 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(condition)
12、; 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(); catch(
13、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 ServletEx
14、ception 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) throws
15、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(Exception
16、 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(loginBe
17、an.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(boo
18、) 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); loginB
19、ean.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; logi
20、nBean.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(request,
21、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 Class.fo
22、rName(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 Connection
23、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.setA
24、ttribute(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.setString
26、(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.setLogname
27、(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.setSu
28、ccess(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 myservl
29、et.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.init(confi
30、g); 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,IOExcep
31、tion 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 request,Ht
32、tpServletResponse 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); Stri
33、ng 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 insert
34、Condition=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.setTime(time); con.close(); catch(SQL
©2010-2024 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100