智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書(shū)及實(shí)訓(xùn)報(bào)告在線(xiàn)考試系統(tǒng)的制作
《智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書(shū)及實(shí)訓(xùn)報(bào)告在線(xiàn)考試系統(tǒng)的制作》由會(huì)員分享,可在線(xiàn)閱讀,更多相關(guān)《智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書(shū)及實(shí)訓(xùn)報(bào)告在線(xiàn)考試系統(tǒng)的制作(44頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
1、 學(xué)校代碼: 10128 學(xué) 號(hào): 201320905047 JSP開(kāi)發(fā)實(shí)訓(xùn)報(bào)告書(shū) 題 目:在線(xiàn)考試系統(tǒng)的制作 學(xué)生姓名:張志勇 學(xué) 院:理學(xué)院 班 級(jí):信計(jì)13-1 指導(dǎo)教師:李曉瑜、宋健、賴(lài)俊峰 二〇一六年一月 一、項(xiàng)目名稱(chēng) 在線(xiàn)考試系統(tǒng)-題庫(kù)子系統(tǒng) 二、功能要求 – a、用戶(hù)管理 – b、課程管理 – c、題庫(kù)管理 三、需求分析 《在線(xiàn)考試系統(tǒng)-題庫(kù)子系統(tǒng)》的用戶(hù)包括用戶(hù)管理員,試題管理員和題庫(kù)使用人
2、員,旨在建立一個(gè)獨(dú)立的題庫(kù)系統(tǒng),為在線(xiàn)考試生成試卷提供支持,包含用戶(hù)管理,科目管理,試題管理,生成試卷,試卷分析等內(nèi)容,為用戶(hù)提供了一個(gè)快速、全面、準(zhǔn)確的試題管理平臺(tái)。 四、設(shè)計(jì)思想 a、使用Java Web技術(shù)實(shí)現(xiàn) b、使用Mysql存儲(chǔ)數(shù)據(jù) c、基于MVC方式實(shí)現(xiàn)用例 設(shè)計(jì)思路:(如下圖) 分步詳解: 第一步:創(chuàng)建項(xiàng)目名(zhangzhiyong); 第二步:創(chuàng)建項(xiàng)目所需要的包; 第三步:導(dǎo)入需要的工具; 第四步:創(chuàng)建數(shù)據(jù)庫(kù)的連接; 第五步:需要的準(zhǔn)備工作做好之后,明確先做用戶(hù)管理系統(tǒng)(登錄,查看,刪除,修改,增加
3、,退出;); 第六步:做好用戶(hù)管理之后進(jìn)行科目管理(增加,刪除,修改,查看;); 第七步:接下來(lái)進(jìn)行知識(shí)點(diǎn)管理(增加,刪除,修改,查看;); 五、具體實(shí)現(xiàn) 一.用戶(hù)管理: 需要的servlet: (user servlet) package cn.zhangzhiyong.service; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletException; import javax.servlet.a
4、nnotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.bean.User; import cn.zhangzhiyong.dao.UserDAO; import cn.zhangzhiyong.util.RequestUtil; @WebServlet("/UserServlet")
5、 public class UserServlet extends HttpServlet { private static final long serialVersionUID = 1L; public UserServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEnc
6、oding("utf-8"); response.setContentType("text/html;charset=utf-8"); PrintWriter out=response.getWriter(); String type=request.getParameter("type"); String userLogname=request.getParameter("userLogname"); String userPwd=request.getParameter("userPwd"); UserDAO dao=new UserDAO();
7、User user=dao.login(userLogname, userPwd); if("login".equals(type)){ if(user!=null){ request.getSession().setAttribute("SESSION_USER",user); response.sendRedirect("res/index.html"); }else{ out.print(""); } }else if("logout".equals(type)){ request.getSession().invalidate(); out.print(""); }else if("list".
9、equals(type)){
List
10、n { doGet(request, response); } } (user add servlet) package cn.zhangzhiyong.service; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet
11、.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.bean.User; import cn.zhangzhiyong.dao.UserDAO; import cn.zhangzhiyong.util.RequestUtil; @WebServlet("/UserAddServlet") public class UserAddServlet extends HttpServlet { private static final long s
12、erialVersionUID = 1L; public UserAddServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String login=request.getParameter
13、("login"); String name=request.getParameter("name"); int type=(request.getParameter("type")==null)? 3:Integer.parseInt(request.getParameter("type")); int status=(request.getParameter("status")==null)? 1:Integer.parseInt(request.getParameter("status")); User user=new User(login,na
14、me,type,status); UserDAO dao=new UserDAO(); int n=dao.save(user); if(n==1){ response.sendRedirect("UserServlet?type=list"); }else{ response.sendRedirect("index.jsp"); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletExc
15、eption, IOException { doGet(request, response); } } (UserDeleteServlet) package cn.zhangzhiyong.service; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.Http
16、ServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.bean.User; import cn.zhangzhiyong.dao.UserDAO; import cn.zhangzhiyong.util.RequestUtil; import cn.zhangzhiyong.util.WebUtil; @WebServlet("/UserDeleteServlet") public class UserDeleteServlet extends HttpSer
17、vlet { private static final long serialVersionUID = 1L; public UserDeleteServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("
18、UTF-8"); // System.out.println(request.getParameter("Id")); int id=RequestUtil.getInt(request,"Id"); UserDAO dao=new UserDAO(); dao.delete(id); WebUtil.forward(request, response, "UserServlet?type=list"); } protected void doPost(HttpServletRequest request, HttpServletR
19、esponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } (UserUpdate1Servlet) package cn.zhangzhiyong.service; import java.io.File; import java.io.IOException; import javax.servlet.ServletException; import javax.servle
20、t.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.Part; import cn.zhangzhiyong.bean.User; import cn.zhangzhiyong.dao.UserDAO; import cn.zhangzhiyong.util.Reques
21、tUtil; import cn.zhangzhiyong.util.WebUtil; @WebServlet("/UserUpdate1Servlet") public class UserUpdate1Servlet extends HttpServlet { private static final long serialVersionUID = 1L; public UserUpdate1Servlet() { super(); } protected void doGet(HttpServletReque
22、st request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int id=RequestUtil.getInt(request,"Id"); request.setAttribute("id", id); request.getRequestDispatcher("
23、res/user-update.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } (UserUpdateServlet) package cn.zhangzhiyong
24、.service; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.bean.User; impor
25、t cn.zhangzhiyong.dao.UserDAO; import cn.zhangzhiyong.util.RequestUtil; @WebServlet("/UserUpdateServlet") public class UserUpdateServlet extends HttpServlet { private static final long serialVersionUID = 1L; public UserUpdateServlet() { super(); } protected void doGet(Ht
26、tpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String login=request.getParameter("login"); String name=request.getParameter("name"); String passwd=request.getParameter("passwd"); int type=Intege
27、r.parseInt(request.getParameter("type")); int status=Integer.parseInt(request.getParameter("status")); int id=RequestUtil.getInt(request,"id"); User users=new User(login,name,type,status); UserDAO dao=new UserDAO(); int n=dao.update(users); if(n==1){ response.sendRedirect("Us
28、erServlet?type=list"); }else{ response.sendRedirect("index.jsp"); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } (UserViewServlet) package cn.zhangzhiyong.service;
29、import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhi
30、yong.bean.User; import cn.zhangzhiyong.dao.UserDAO; import cn.zhangzhiyong.util.RequestUtil; @WebServlet("/UserViewServlet") public class UserViewServlet extends HttpServlet { private static final long serialVersionUID = 1L; public UserViewServlet() { super(); } pro
31、tected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); PrintWriter out=response.getWriter(); String type=request.getParameter("type");
32、 String userLogname=request.getParameter("userLogname"); String userPwd=request.getParameter("userPwd"); UserDAO dao=new UserDAO(); int id=RequestUtil.getInt(request,"Id"); User user1=dao.selectById(id); request.setAttribute("user",user1); request.getRequestDispatcher("res/user-sho
33、w.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } 需要的類(lèi): package cn.zhangzhiyong.bean; import java.sql.Timestamp; public class User { publ
34、ic static final String passwd="123456"; private int id; private String login; private String name; private String password; private int type; private int status; private Timestamp last_login; public User(String login2, String name2, int type2, int status2) { super(); this.logi
35、n=login2; this.name=name2; this.type=type2; this.status=status2; } public User() { } public User(int id2) { this.id=id2; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getLogin() { return login; } public void
36、 setLogin(String login) { this.login = login; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } p
37、ublic int getType() { return type; } public void setType(int type) { this.type = type; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public Timestamp getLast_login() { return last_login; } public void setLas
38、t_login(Timestamp last_login) { this.last_login = last_login; } } 需要的dao: package cn.zhangzhiyong.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; i
39、mport cn.zhangzhiyong.bean.User; import cn.zhangzhiyong.util.DBUtil; public class UserDAO { //userdao中的save方法 public int save(User user){ int n=-1; Connection conn=DBUtil.getConnection();//連接對(duì)象 PreparedStatement pstmt=null;//語(yǔ)句對(duì)象 //下邊是s語(yǔ)句 String sql="insert into userss" +
40、" values(DL_USERSS.NEXTVAL,?,?,123456,?,?,sysdate)"; try{ pstmt=conn.prepareStatement(sql); pstmt.setString(1, user.getLogin()); pstmt.setString(2, user.getName()); pstmt.setInt(3, user.getType()); pstmt.setInt(4, user.getStatus()); n=pstmt.executeUpdate();//n=更新的行數(shù) }catc
41、h(SQLException e){ e.printStackTrace(); }finally{ DBUtil.closeJDBC(null, pstmt, conn); } return n; } public User login(String userLogname, String userPwd) { Connection conn=DBUtil.getConnection(); PreparedStatement pstmt=null; ResultSet rs=null; User u=null; Strin
42、g sql="select id,login,name,passwd,type,status,last_login" + " from users where login=? and passwd=?"; try{ pstmt=conn.prepareStatement(sql); pstmt.setString(1, userLogname); pstmt.setString(2, userPwd); rs=pstmt.executeQuery(); if(rs.next()){ u=new User(); u.se
43、tId(rs.getInt(1)); u.setLogin(rs.getString(2)); u.setName(rs.getString(3)); u.setPassword(rs.getString(4)); u.setType(rs.getInt(5)); u.setStatus(rs.getInt(6)); u.setLast_login(rs.getTimestamp(7)); } }catch(SQLException e){ e.printStackTrace(); }finally{
44、 DBUtil.closeJDBC(rs, pstmt, conn); } return u; } public User selectById(int Id) { User user=new User(); Connection conn=DBUtil.getConnection(); PreparedStatement pstmt=null; ResultSet rs=null; String sql="select * from userss where id=?"; try{ pstmt=conn.prepareStat
45、ement(sql); pstmt.setInt(1, Id); rs=pstmt.executeQuery(); if(rs.next()){ user.setId(rs.getInt(1)); user.setLogin(rs.getString(2)); user.setName(rs.getString(3)); user.setPassword(rs.getString(4)); user.setType(rs.getInt(5)); user.setStatus(rs.getInt(6));
46、 }
}catch(SQLException e){
e.printStackTrace();
}finally{
DBUtil.closeJDBC(rs, pstmt, conn);
}
return user;
}
public List
47、ull; String sql="select * from userss order by id desc"; try{ pstmt=conn.prepareStatement(sql); rs=pstmt.executeQuery(); while(rs.next()){ User user=new User(); user.setId(rs.getInt(1)); user.setLogin(rs.getString(2)); user.setName(rs.getString(3)); user.setPasswor
48、d(rs.getString(4)); user.setType(rs.getInt(5)); user.setStatus(rs.getInt(6)); list.add(user); } }catch(SQLException e){ e.printStackTrace(); }finally{ DBUtil.closeJDBC(rs, pstmt, conn); } return list; } //userdao中的update方法 public int update(User users){ int n
49、=-1; Connection conn=DBUtil.getConnection();//連接對(duì)象 PreparedStatement pstmt=null;//語(yǔ)句對(duì)象 String sql="update userss" + " set login=?,name=?,passwd=123,type=?,status=? where id=?"; try{ pstmt=conn.prepareStatement(sql); pstmt.setString(1, users.getLogin()); pstmt.setString(2,
50、users.getName()); pstmt.setInt(3, users.getType()); pstmt.setInt(4, users.getStatus()); pstmt.setInt(5,users.getId()); n=pstmt.executeUpdate();//n=更新的行數(shù) }catch(SQLException e){ e.printStackTrace(); }finally{ DBUtil.closeJDBC(null, pstmt, conn); } return n; }
51、 //userdao中的delete 方法 public int delete(int id){ int m=-1; Connection conn=DBUtil.getConnection();//連接對(duì)象 PreparedStatement pstmt=null;//語(yǔ)句對(duì)象 String sql="delete from userss where id=?"; try{ pstmt=conn.prepareStatement(sql); pstmt.setInt(1,id); m=pstmt.exec
52、uteUpdate();//n=更新的行數(shù) }catch(SQLException e){ e.printStackTrace(); }finally{ DBUtil.closeJDBC(null, pstmt, conn); } return m; } } 二.科目管理: 需要的servlet: (SubjectViewServlet) package cn.zhangzhiyong.service; import java.io.IOException; import javax.servlet.ServletExcept
53、ion; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.bean.Subject; import cn.zhangzhiyong.dao.SubjectDAO; import cn.zhangzhiyong.util.Reques
54、tUtil; /** * Servlet implementation class SubjectViewServlet */ @WebServlet("/SubjectViewServlet") public class SubjectViewServlet extends HttpServlet { private static final long serialVersionUID = 1L; public SubjectViewServlet() { super(); }
55、 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); SubjectDAO dao=new SubjectDAO(); int id=RequestUtil.getInt(request,"id"
56、); Subject subject=dao.selectById(id); request.setAttribute("Subject",subject); request.getRequestDispatcher("res/subject-show.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
57、 doGet(request, response); } } (SubjectUpdate2Servlet) package cn.zhangzhiyong.service; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletReque
58、st; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.bean.Subject; import cn.zhangzhiyong.dao.SubjectDAO; import cn.zhangzhiyong.util.RequestUtil; @WebServlet("/SubjectUpdate2Servlet") public class SubjectUpdate2Servlet extends HttpServlet { private static final lo
59、ng serialVersionUID = 1L; public SubjectUpdate2Servlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Subject subject =new Subject(); subject.setKname(Reques
60、tUtil.getString(request, "kname")); subject.setType(RequestUtil.getInt(request, "type")); subject.setKint(RequestUtil.getString(request, "kint")); subject.setId(RequestUtil.getInt(request, "id")); SubjectDAO dao=new SubjectDAO(); int n=dao.update(subject); response.sendRedi
61、rect("ServletListServlet?type=list"); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } (SubjectUpdate0Servlet) package cn.zhangzhiyong.service; import java.io.IOException; i
62、mport javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.bean.Subject; import cn.zhangzhiyong.dao.SubjectDAO; i
63、mport cn.zhangzhiyong.util.RequestUtil; /** * Servlet implementation class SubjectUpdate0Servlet */ @WebServlet("/SubjectUpdate0Servlet") public class SubjectUpdate0Servlet extends HttpServlet { private static final long serialVersionUID = 1L; public SubjectUpdate0Serv
64、let() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); SubjectDAO dao=new SubjectDAO();
65、 int id=RequestUtil.getInt(request,"id"); Subject subject=dao.selectById(id); request.setAttribute("Subject",subject); request.getRequestDispatcher("res/subject-update.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse respo
66、nse) throws ServletException, IOException { doGet(request, response); } } (SubjectListServlet) package cn.zhangzhiyong.service; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.zhangzhiyong.dao.SubjectDAO; import cn.zhangzhiyong.bea
- 溫馨提示:
1: 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 平均數(shù)課件(教育精品)
- 婦科腫瘤放療進(jìn)展
- 注射機(jī)有關(guān)參數(shù)校核
- 五年級(jí)科學(xué)維護(hù)生態(tài)平衡-PPT
- 心臟術(shù)后觀察及監(jiān)護(hù)要點(diǎn)
- 生本教育從改變自己開(kāi)始
- 部編版一年級(jí)下冊(cè)《文具的家》課件
- 人教初中地理八上《1第2節(jié)-人口》課件-(10)
- 部編小學(xué)二年級(jí)下冊(cè)語(yǔ)文傳統(tǒng)節(jié)日課件
- 《科學(xué)探究:歐姆定律》課件-(公開(kāi)課獲獎(jiǎng))2022年滬科版物理-
- S7-1200-PLC應(yīng)用基礎(chǔ)ppt課件第8章-PLC應(yīng)用系統(tǒng)設(shè)計(jì)實(shí)例
- 人教版五年級(jí)下冊(cè)長(zhǎng)方體和正方體《求不規(guī)則物體的體積》課件
- 中職版《走進(jìn)物流》ppt課件模塊二-項(xiàng)目一-走進(jìn)貨運(yùn)物流
- 中考?xì)v史一輪復(fù)習(xí)-侵略與反抗課件-新人教版
- 肝功能障礙患者合理用藥房文通課件