![智能移動方向Jsp開發(fā)實訓任務書及實訓報告在線考試系統(tǒng)的制作_第1頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/1/d266d728-385b-4358-b1ca-f0656872b2a4/d266d728-385b-4358-b1ca-f0656872b2a41.gif)
![智能移動方向Jsp開發(fā)實訓任務書及實訓報告在線考試系統(tǒng)的制作_第2頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/1/d266d728-385b-4358-b1ca-f0656872b2a4/d266d728-385b-4358-b1ca-f0656872b2a42.gif)
![智能移動方向Jsp開發(fā)實訓任務書及實訓報告在線考試系統(tǒng)的制作_第3頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/1/d266d728-385b-4358-b1ca-f0656872b2a4/d266d728-385b-4358-b1ca-f0656872b2a43.gif)
![智能移動方向Jsp開發(fā)實訓任務書及實訓報告在線考試系統(tǒng)的制作_第4頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/1/d266d728-385b-4358-b1ca-f0656872b2a4/d266d728-385b-4358-b1ca-f0656872b2a44.gif)
![智能移動方向Jsp開發(fā)實訓任務書及實訓報告在線考試系統(tǒng)的制作_第5頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/1/d266d728-385b-4358-b1ca-f0656872b2a4/d266d728-385b-4358-b1ca-f0656872b2a45.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、 學校代碼: 10128 學 號: 201320905047 jsp開發(fā)實訓報告書題 目:在線考試系統(tǒng)的制作學生姓名:張志勇學 院:理學院班 級:信計13-1指導教師:李曉瑜、宋健、賴俊峰 二一六年一月一、項目名稱在線考試系統(tǒng)-題庫子系統(tǒng)二、功能要求 a、用戶管理 b、課程管理 c、題庫管理 三、需求分析 在線考試系統(tǒng)-題庫子系統(tǒng)的用戶包括用戶管理員,試題管理員和題庫使用人員,旨在建立一個獨立的題庫系統(tǒng),為在線考試生成試卷提供支持,包含用戶管理,科目管理,試題管理,生成試卷,試卷分析等內容,為用戶提供了一個快速、全面、準確的試題管理平臺。四、設計思想 a、使用java web技術實現(xiàn) b、使用
2、mysql存儲數(shù)據(jù) c、基于mvc方式實現(xiàn)用例設計思路:(如下圖)分步詳解:第一步:創(chuàng)建項目名(zhangzhiyong);第二步:創(chuàng)建項目所需要的包;第三步:導入需要的工具;第四步:創(chuàng)建數(shù)據(jù)庫的連接;第五步:需要的準備工作做好之后,明確先做用戶管理系統(tǒng)(登錄,查看,刪除,修改,增加,退出;);第六步:做好用戶管理之后進行科目管理(增加,刪除,修改,查看;);第七步:接下來進行知識點管理(增加,刪除,修改,查看;);五、具體實現(xiàn)一用戶管理:需要的servlet:(user servlet)package cn.zhangzhiyong.service;import java.io.ioexce
3、ption;import java.io.printwriter;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.bean.user;im
4、port cn.zhangzhiyong.dao.userdao;import cn.zhangzhiyong.util.requestutil;webservlet("/userservlet")public class userservlet extends httpservlet private static final long serialversionuid = 1l; public userservlet() super(); protected void doget(httpservletrequest request, httpservletrespons
5、e response) throws servletexception, ioexception request.setcharacterencoding("utf-8");response.setcontenttype("text/html;charset=utf-8");printwriter out=response.getwriter();string type=request.getparameter("type");string userlogname=request.getparameter("userlogn
6、ame");string userpwd=request.getparameter("userpwd");userdao dao=new userdao();user user=dao.login(userlogname, userpwd);if("login".equals(type)if(user!=null)request.getsession().setattribute("session_user",user);response.sendredirect("res/index.html");el
7、seout.print("<script type='text/javascript'>");out.print("alert('用戶名或密碼錯誤,請重新輸入!');");out.print("window.location='login.jsp'");out.print("</script>");else if("logout".equals(type)request.getsession().invalidate();o
8、ut.print("<script type='text/javascript'>");out.print("window.location='login.jsp'");out.print("</script>");else if("list".equals(type)list<user> list=dao.selectall();request.setattribute("list",list);request.getrequ
9、estdispatcher("res/user.jsp").forward(request, response);protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception doget(request, response);(user add servlet)package cn.zhangzhiyong.service;import java.io.ioexception;import java.io
10、.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.zhangzhiyong.bean.user;import cn.zhangzhiyong.dao.userdao;import cn
11、.zhangzhiyong.util.requestutil;webservlet("/useraddservlet")public class useraddservlet extends httpservlet private static final long serialversionuid = 1l; public useraddservlet() super(); protected void doget(httpservletrequest request, httpservletresponse response) throws servletexcepti
12、on, ioexception request.setcharacterencoding("utf-8");string login=request.getparameter("login");string name=request.getparameter("name");int type=(request.getparameter("type")=null)?3:integer.parseint(request.getparameter("type");int status=(request
13、.getparameter("status")=null)?1:integer.parseint(request.getparameter("status");user user=new user(login,name,type,status);userdao dao=new userdao();int n=dao.save(user);if(n=1)response.sendredirect("userservlet?type=list");elseresponse.sendredirect("index.jsp"
14、;);protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception doget(request, response);(userdeleteservlet)package cn.zhangzhiyong.service;import java.io.ioexception;import javax.servlet.servletexception;import javax.servlet.annotation.webserv
15、let;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;import cn.zhangzhiyong.util.webutil;webservlet("/userd
16、eleteservlet")public class userdeleteservlet extends httpservlet private static final long serialversionuid = 1l; public userdeleteservlet() super(); protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception request.setcharacterencoding(
17、"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, httpser
18、vletresponse response) throws servletexception, ioexception / todo auto-generated method stubdoget(request, response);(userupdate1servlet)package cn.zhangzhiyong.service;import java.io.file;import java.io.ioexception;import javax.servlet.servletexception;import javax.servlet.annotation.webservlet;im
19、port 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.requestutil;import cn.zhangzhiyong.util.webuti
20、l;webservlet("/userupdate1servlet")public class userupdate1servlet extends httpservlet private static final long serialversionuid = 1l; public userupdate1servlet() super(); protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception r
21、equest.setcharacterencoding("utf-8");response.setcontenttype("text/html;charset=utf-8");int id=requestutil.getint(request,"id"); request.setattribute("id", id); request.getrequestdispatcher("res/user-update.jsp").forward(request, response); protected
22、 void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception / todo auto-generated method stubdoget(request, response);(userupdateservlet)package cn.zhangzhiyong.service;import java.io.ioexception;import javax.servlet.servletexception;import javax.servl
23、et.annotation.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("/userupdateservlet&qu
24、ot;)public class userupdateservlet extends httpservlet private static final long serialversionuid = 1l; public userupdateservlet() super(); protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception request.setcharacterencoding("utf-8&quo
25、t;);string login=request.getparameter("login");string name=request.getparameter("name");string passwd=request.getparameter("passwd");int type=integer.parseint(request.getparameter("type");int status=integer.parseint(request.getparameter("status");int
26、 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("userservlet?type=list");elseresponse.sendredirect("index.jsp");protected void dopost(httpservletrequest reque
27、st, httpservletresponse response) throws servletexception, ioexception doget(request, response);(userviewservlet)package cn.zhangzhiyong.service;import java.io.ioexception;import java.io.printwriter;import javax.servlet.servletexception;import javax.servlet.annotation.webservlet;import javax.servlet
28、.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("/userviewservlet")public class userviewservlet extends httpse
29、rvlet private static final long serialversionuid = 1l; public userviewservlet() super(); protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception request.setcharacterencoding("utf-8");response.setcontenttype("text/html;charset
30、=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();int id=requestutil.getint(request,"id");
31、user user1=dao.selectbyid(id);request.setattribute("user",user1);request.getrequestdispatcher("res/user-show.jsp").forward(request, response);protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception doget(request, respon
32、se);需要的類:package cn.zhangzhiyong.bean;import java.sql.timestamp;public class user public 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 l
33、ogin2, string name2, int type2, int status2) super();this.login=login2;=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 setlogin(str
34、ing login) this.login = login;public string getname() return name;public void setname(string name) = name;public string getpassword() return password;public void setpassword(string password) this.password = password;public int gettype() return type;public void settype(int type) this.type =
35、 type;public int getstatus() return status;public void setstatus(int status) this.status = status;public timestamp getlast_login() return last_login;public void setlast_login(timestamp last_login) this.last_login = last_login;需要的dao:package cn.zhangzhiyong.dao;import java.sql.connection;import java.
36、sql.preparedstatement;import java.sql.resultset;import java.sql.sqlexception;import java.util.arraylist;import java.util.list;import 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.getconnecti
37、on();/連接對象preparedstatement pstmt=null;/語句對象/下邊是s語句string sql="insert into userss"+" values(dl_userss.nextval,?,?,'123456',?,?,sysdate)"trypstmt=conn.preparestatement(sql);pstmt.setstring(1, user.getlogin();pstmt.setstring(2, user.getname();pstmt.setint(3, user.gettype();
38、pstmt.setint(4, user.getstatus();n=pstmt.executeupdate();/n=更新的行數(shù)catch(sqlexception e)e.printstacktrace();finallydbutil.closejdbc(null, pstmt, conn);return n;public user login(string userlogname, string userpwd) connection conn=dbutil.getconnection();preparedstatement pstmt=null;resultset rs=null;us
39、er u=null;string sql="select id,login,name,passwd,type,status,last_login"+ " from users where login=? and passwd=?"trypstmt=conn.preparestatement(sql);pstmt.setstring(1, userlogname);pstmt.setstring(2, userpwd);rs=pstmt.executequery();if(rs.next()u=new user();u.setid(rs.getint(1)
40、;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();finallydbutil.closejdbc(rs, pstmt, conn);return u;public user selectbyid(int id) user user=n
41、ew user();connection conn=dbutil.getconnection();preparedstatement pstmt=null;resultset rs=null;string sql="select * from userss where id=?"trypstmt=conn.preparestatement(sql);pstmt.setint(1, id);rs=pstmt.executequery();if(rs.next()user.setid(rs.getint(1);user.setlogin(rs.getstring(2);user
42、.setname(rs.getstring(3);user.setpassword(rs.getstring(4);user.settype(rs.getint(5);user.setstatus(rs.getint(6);catch(sqlexception e)e.printstacktrace();finallydbutil.closejdbc(rs, pstmt, conn);return user;public list<user> selectall()list<user> list=new arraylist<user>();connectio
43、n conn=dbutil.getconnection();preparedstatement pstmt=null;resultset rs=null;string sql="select * from userss order by id desc"trypstmt=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(
44、rs.getstring(3);user.setpassword(rs.getstring(4);user.settype(rs.getint(5);user.setstatus(rs.getint(6);list.add(user);catch(sqlexception e)e.printstacktrace();finallydbutil.closejdbc(rs, pstmt, conn);return list;/userdao中的update方法public int update(user users)int n=-1;connection conn=dbutil.getconnec
45、tion();/連接對象preparedstatement pstmt=null;/語句對象string sql="update userss" + " set login=?,name=?,passwd=123,type=?,status=? where id=?"trypstmt=conn.preparestatement(sql);pstmt.setstring(1, users.getlogin();pstmt.setstring(2, users.getname();pstmt.setint(3, users.gettype();pstmt.s
46、etint(4, users.getstatus();pstmt.setint(5,users.getid();n=pstmt.executeupdate();/n=更新的行數(shù)catch(sqlexception e)e.printstacktrace();finallydbutil.closejdbc(null, pstmt, conn);return n;/userdao中的delete 方法public int delete(int id)int m=-1;connection conn=dbutil.getconnection();/連接對象preparedstatement pstm
47、t=null;/語句對象string sql="delete from userss where id=?"trypstmt=conn.preparestatement(sql);pstmt.setint(1,id);m=pstmt.executeupdate();/n=更新的行數(shù)catch(sqlexception e)e.printstacktrace();finallydbutil.closejdbc(null, pstmt, conn);return m;二科目管理:需要的servlet:(subjectviewservlet)package cn.zhangzhi
48、yong.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.subject;import cn.zhan
49、gzhiyong.dao.subjectdao;import cn.zhangzhiyong.util.requestutil;/* * servlet implementation class subjectviewservlet */webservlet("/subjectviewservlet")public class subjectviewservlet extends httpservlet private static final long serialversionuid = 1l; public subjectviewservlet() super();
50、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&
51、quot;);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 d
52、oget(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.httpservletrequest;import javax.servlet.http.http
53、servletresponse;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 long serialversionuid = 1l; public subjectupdate
54、2servlet() super(); protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception subject subject =new subject();subject.setkname(requestutil.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.sendredirect("servletlis
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 樓板拆除回頂施工方案
- 個人盆景出售合同范例
- CNAS認可合同范例
- 2001融資租賃合同范例
- 臨時綠化合同范例
- 合資房協(xié)議合同范例
- 軍品售后合同范本
- 不合格裝修合同范例
- 單層廠房購買合同范例
- 全房定制合同范例
- 大學生就業(yè)指導PPT(第2版)全套完整教學課件
- 家具安裝工培訓教案優(yōu)質資料
- 湖南大一型抽水蓄能電站施工及質量創(chuàng)優(yōu)匯報
- 耳穴療法治療失眠
- 少兒財商教育少兒篇
- GB 1886.114-2015食品安全國家標準食品添加劑紫膠(又名蟲膠)
- 初二上冊期末數(shù)學試卷含答案
- envi二次開發(fā)素材包-idl培訓
- 2022年上海市初中語文課程終結性評價指南
- 西門子starter軟件簡易使用手冊
- 隧道施工監(jiān)控量測方案及措施
評論
0/150
提交評論