智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書及實(shí)訓(xùn)報(bào)告在線考試系統(tǒng)的制作_第1頁(yè)
智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書及實(shí)訓(xùn)報(bào)告在線考試系統(tǒng)的制作_第2頁(yè)
智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書及實(shí)訓(xùn)報(bào)告在線考試系統(tǒng)的制作_第3頁(yè)
智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書及實(shí)訓(xùn)報(bào)告在線考試系統(tǒng)的制作_第4頁(yè)
智能移動(dòng)方向Jsp開(kāi)發(fā)實(shí)訓(xùn)任務(wù)書及實(shí)訓(xùn)報(bào)告在線考試系統(tǒng)的制作_第5頁(yè)
已閱讀5頁(yè),還剩39頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 學(xué)校代碼: 10128 學(xué) 號(hào): 201320905047 jsp開(kāi)發(fā)實(shí)訓(xùn)報(bào)告書題 目:在線考試系統(tǒng)的制作學(xué)生姓名:張志勇學(xué) 院:理學(xué)院班 級(jí):信計(jì)13-1指導(dǎo)教師:李曉瑜、宋健、賴俊峰 二一六年一月一、項(xiàng)目名稱在線考試系統(tǒng)-題庫(kù)子系統(tǒng)二、功能要求 a、用戶管理 b、課程管理 c、題庫(kù)管理 三、需求分析 在線考試系統(tǒng)-題庫(kù)子系統(tǒng)的用戶包括用戶管理員,試題管理員和題庫(kù)使用人員,旨在建立一個(gè)獨(dú)立的題庫(kù)系統(tǒng),為在線考試生成試卷提供支持,包含用戶管理,科目管理,試題管理,生成試卷,試卷分析等內(nèi)容,為用戶提供了一個(gè)快速、全面、準(zhǔn)確的試題管理平臺(tái)。四、設(shè)計(jì)思想 a、使用java web技術(shù)實(shí)現(xiàn) b、使用

2、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)備工作做好之后,明確先做用戶管理系統(tǒng)(登錄,查看,刪除,修改,增加,退出;);第六步:做好用戶管理之后進(jìn)行科目管理(增加,刪除,修改,查看;);第七步:接下來(lái)進(jìn)行知識(shí)點(diǎn)管理(增加,刪除,修改,查看;);五、具體實(shí)現(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('用戶名或密碼錯(cuò)誤,請(qǐng)重新輸入!');");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();/連接對(duì)象preparedstatement pstmt=null;/語(yǔ)句對(duì)象/下邊是s語(yǔ)句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();/連接對(duì)象preparedstatement pstmt=null;/語(yǔ)句對(duì)象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();/連接對(duì)象preparedstatement pstm

47、t=null;/語(yǔ)句對(duì)象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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論