版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
昆明理工大學(xué)信息工程與自動(dòng)化學(xué)院學(xué)生實(shí)驗(yàn)報(bào)告(2012—2013學(xué)年第一學(xué)期)課程名稱:JAVAEE技術(shù)開課實(shí)驗(yàn)室:信自樓4442012年12月19日年級(jí)、專業(yè)、班計(jì)科10級(jí)學(xué)號(hào)姓名成績實(shí)驗(yàn)項(xiàng)目名稱實(shí)驗(yàn)三Jsp+Javabean+JSTL綜合設(shè)計(jì)指導(dǎo)教師楊云飛教師評(píng)語教師簽名:年月日一、實(shí)驗(yàn)?zāi)康耐ㄟ^上機(jī),熟練掌握J(rèn)SP編程、JavaBean的應(yīng)用以及EL和JSTL的應(yīng)用。二、內(nèi)容及要求1、上機(jī)內(nèi)容:編寫兩個(gè)JavaBean,實(shí)現(xiàn)值類和業(yè)務(wù)類。編寫servlet實(shí)現(xiàn)控制的功能;編寫top.jsp、left.jsp、bottom.jsp、employeemain.jsp,實(shí)現(xiàn)頁面的組裝。在left.jsp增加登錄部分,若登錄成功后在同樣的位置顯示:歡迎您和用戶號(hào)。在top.jsp中增加兩個(gè)鏈接,實(shí)現(xiàn)投票和管理投票中心,其中管理投票中心只有在登錄成功后方顯示。。三、步驟及具體實(shí)施1、簡要描述程序的開發(fā)流程、文件部署截圖、及各種配置;2、程序代碼packagechapter10.dao;importjava.util.*;importjava.sql.*;importchapter10.value.EmployeeValue;publicclassEmployeeBusiness{ publicListgetList()throwsException { ListempList=newArrayList(); Stringsql="select*fromuserinfo"; Connectioncn=null; try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); cn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=javaee","root","123"); Statementstmt=cn.createStatement(); //PreparedStatementps=cn.prepareStatement(sql); ResultSetrs=stmt.executeQuery(sql); while(rs.next()) { EmployeeValueev=newEmployeeValue(); ev.setUserId(rs.getString("userid")); ev.setPassWord(rs.getString("password")); ev.setName(rs.getString("name")); ev.setAge(rs.getInt("age")); empList.add(ev); } rs.close(); stmt.close(); } catch(Exceptione) { thrownewException("取得員工列表錯(cuò)誤:"+e.getMessage()); } finally { cn.close(); } returnempList; }}importjavax.servlet.Filter;importjavax.servlet.FilterChain;importjavax.servlet.FilterConfig;importjavax.servlet.ServletException;importjavax.servlet.ServletRequest;importjavax.servlet.ServletResponse;importjavax.servlet.http.HttpServletRequestWrapper;importjavax.servlet.http.*;//請(qǐng)求數(shù)據(jù)字符編碼處理過濾器publicclassCharEncodingFilterimplementsFilter{ privateFilterConfigconfig=null; privateStringcontentType=null; privateStringcode=null; //初始化方法,在過濾器對(duì)象創(chuàng)建后被調(diào)用 publicvoidinit(FilterConfigconfig)throwsServletException { this.config=config; //取得Filter初始化參數(shù) //contentType=config.getInitParameter("contentType"); code=config.getInitParameter("encoding"); System.out.println("init..."); } //過濾方法 publicvoiddoFilter(ServletRequestreq,ServletResponseres, FilterChainchain)throwsIOException,ServletException { //轉(zhuǎn)換為HTTP請(qǐng)求對(duì)象 HttpServletRequestrequest=(HttpServletRequest)req; //request.setAttribute("infoType","image/jpeg"); request.setCharacterEncoding(code);//設(shè)置字符編碼集 res.setCharacterEncoding(code);//設(shè)置字符編碼集 System.out.println("filting..."); //繼續(xù)下個(gè)過濾器 chain.doFilter(req,res); } //銷毀方法,在過濾器銷毀前被調(diào)用 publicvoiddestroy() { System.out.println("destroy..."); }}<%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%><%@tagliburi="/jsp/jstl/core"prefix="c"%><%@tagliburi="/jsp/jstl/fmt"prefix="fmt"%><%@tagliburi="/jsp/jstl/sql"prefix="sql"%><%@tagliburi="/jsp/jstl/xml"prefix="x"%><%@tagliburi="/jsp/jstl/functions"prefix="fn"%><%Stringd_id=(String)(request.getParameter("id"));System.out.println("d_id="+d_id);%><sql:setDataSourcedriver="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost/cityoa"user="root"password="abc123"var="infoData"scope="request"/><sql:updatesql="updateuserinfo1setTYPE=?WhereUSERID=?"dataSource="${infoData}"var="result"scope="request"><sql:paramvalue="black"/><sql:paramvalue="<%=d_id%>"/></sql:update><jsp:forwardpage="admin.jsp"/>Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><jsp:useBeanid="now"class="java.util.Date"></jsp:useBean><% request.setCharacterEncoding("gb2312"); HttpSessionsession1=request.getSession(); //取得會(huì)話對(duì)象中保存的驗(yàn)證碼,由驗(yàn)證碼生成Servlet存入 Stringuserid=(String)session1.getAttribute("userid"); Stringnote1=request.getParameter("note1"); %><sql:setDataSourcedriver="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost/cityoa"user="root"password="abc123"var="infoData"scope="request"/><sql:updatesql="insertintonotes(id,note,dates)values(?,?,?)"dataSource="${infoData}"var="result"scope="request"> <sql:paramvalue="${userid}"/><sql:paramvalue="<%=note1%>"/><sql:paramvalue="${now}"/></sql:update><jsp:forwardpage="luntan.jsp"/><%@pagecontentType="text/html;charset=GBK"%><%@pagelanguage="java"import="java.sql.*"%><jsp:useBeanid="connDbBean"scope="page"class="javaee.ch04.VoteConn"/><%request.setCharacterEncoding("gb2312");Stringuserid=request.getParameter("userid");Stringname=request.getParameter("name");//Stringpassword=request.getParameter("password"); //Stringrepassword=request.getParameter("repassword"); //Stringusername=request.getParameter("name"); //Filepathname=newFile("F:/apache-tomcat-7.0.23/webapps/04/20.jpg"); //FileInputStreamfilename=newFileInputStream(pathname); //Stringphoto=BinaryStream(//filename,(int)name.length());Stringsql="insertintouserinfo1(USERID,PASSWORD,NAME,SEX,ADDRESS,TEXT,PATH)";sql=sql+"values('"+userid+"','"+userid+"','"+name+"',"+"'man','云南','mynameisben','')";System.out.println("sql:"+sql); connDbBean.executeUpdate(sql);%><jsp:forwardpage="admin.jsp"/><%@pagecontentType="text/html;charset=GBK"%><%@pagelanguage="java"import="java.sql.*"%><jsp:useBeanid="connDbBean"scope="page"class="javaee.ch04.VoteConn"/><%request.setCharacterEncoding("gb2312");Stringuserid=request.getParameter("userid");Stringname=request.getParameter("name");//Stringpassword=request.getParameter("password"); //Stringrepassword=request.getParameter("repassword"); //Stringusername=request.getParameter("name"); //Filepathname=newFile("F:/apache-tomcat-7.0.23/webapps/04/20.jpg"); //FileInputStreamfilename=newFileInputStream(pathname); //Stringphoto=BinaryStream(//filename,(int)name.length());Stringsql="insertintouserinfo1(USERID,PASSWORD,NAME,SEX,ADDRESS,TEXT,PATH)";sql=sql+"values('"+userid+"','"+userid+"','"+name+"',"+"'man','云南','mynameisben','')";System.out.println("sql:"+sql); connDbBean.executeUpdate(sql);%><jsp:forwardpage="admin.jsp"/><%@pagecontentType="text/html;charset=GBK"%><%@pagelanguage="java"import="java.sql.*"%><jsp:useBeanid="connDbBean"scope="page"class="javaee.ch04.VoteConn"/><%request.setCharacterEncoding("gb2312");Stringnn=request.getParameter("note");if(nn!=null&&nn.length()>0){ ResultSettmpRs=connDbBean.executeQuery("selectmax(id)Asmaxidfromvote");tmpRs.next();intmax_id=tmpRs.getInt("maxid")+1;tmpRs.close();Stringsql="insertintovotevalues("+max_id+",'"; sql+=nn+"',0);"; connDbBean.executeUpdate(sql);}x="c"%><jsp:useBeanid="connDbBean"scope="page"class="javaee.ch04.VoteConn"/><html><bodybgcolor="#FFFFFF"><%@includefile="/gl_top.jsp"%><p><fontcolor="#990000"size="+2"><u>同學(xué)信息維護(hù)中心</u></font></p><% ResultSettempRs=connDbBean.executeQuery("SELECTUSERID,NAME,TYPEFROMuserinfo1");%><tablewidth="80%"border="0"cellspacing="1"cellpadding="2"><tr><tdwidth="10%"class="text1"bgcolor="#99CCFF"><divalign="center">用戶ID</div></td><tdwidth="40%"class="text1"bgcolor="#99CCFF"><divalign="center">姓名</div></td><tdwidth="20%"class="text1"bgcolor="#99CCFF"><divalign="center">類型</div></td><tdwidth="10%"class="text1"bgcolor="#99CCFF"><divalign="center">刪除</div></td><tdwidth="20%"class="text1"bgcolor="#99CCFF"><divalign="center">操作</div></td></tr><%inti=1; i=i+1;}s="text1"colspan="2"> </td></tr><tr><tdclass="text1"colspan="3"bgcolor="#99CCFF">增加用戶</td></tr><tr><tdclass="text1"colspan="3"><formmethod="post"action="adduser_gl.jsp"><p>賬號(hào):<inputtype="text"name="userid"size="50"maxlength="50"></p><p>用戶名:<inputtype="text"name="name"size="50"maxlength="50"></p><p><inputtype="submit"name="Submit"value="提交"><inputtype="reset"name="Submit2"value="重置">Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><jsp:useBeanid="connDbBean"scope="page"class="javaee.ch04.VoteConn"/><%Stringd_id=request.getParameter("id");if(d_id!=null&&d_id.length()>0){connDbBean.executeUpdate("updateuserinfo1setTYPE=nullWhereUSERID="+d_id);}ngd_id=(String)(request.getParameter("id"));System.out.println("d_id="+d_id);%><sql:setDataSourcedriver="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost/cityoa"user="root"password="abc123"var="infoData"scope="request"/><sql:updatesql="DELETEFROMnotesWhereid=?"dataSource="${infoData}"ngd_id=(String)(request.getParameter("id"));System.out.println("d_id="+d_id);%><sql:setDataSourcedriver="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost/cityoa"user="root"password="abc123"ringd_id=request.getParameter("id");//if(d_id!=null&&d_id.length()>0){System.out.println("要?jiǎng)h除的id為:"+request.getParameter("id"));connDbBean.executeUpdate("DELETEFROMuserinfo1WhereUSERID="+d_id);//}%><jsp:forwardpage="admin.jsp"/><%@pagelanguage="java"import="java.sql.*"%><jsp:useBeanid="connDbBean"scope="page"class="javaee.ch04.VoteConn"/><%Stringd_id=request.getParameter("id");if(d_id!=null&&d_id.length()>0){connDbBean.executeUpdate("DELETEFROMVOTEWhereid="+d_id);}tot_num=0;inttmp_num=0;//獲取總票數(shù)ResultSettmpRs=connDbBean.executeQuery("selectsum(c_num)Astotalnumfromvote");tmpRs.next();tot_num=tmpRs.getInt("totalnum");tmpRs.close();ResultSetrs=connDbBean.executeQuery("select*fromvote");inti=1;while(rs.next()){%> <% tmp_num=rs.getInt("c_num"); %> <tdvalign="bottom"align="center">投票率:<%=Math.floor(tmp_num*100/tot_num)%></br> <imgsrc="back.gif"width="10"height="<%=Math.floor(tmp_num*200/tot_num)%>"></br> <hr> 選項(xiàng)<%=i%>:<%=rs.getString("note")%> </td><%i++;}%></tr></table><ahref="main.jsp">返回</a><%rs.close();%></BODY></HTML><%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%><divstyle="margin:10px10px20px30px;width:1024px;height:222px;background:url(head.jpg)"><divstyle="margin:192px0px0px;width:1024px;height:30px;"><tablewidth="100%"height="100%"border="0"cellspacing="0"cellpadding="0"><trvalign="bottom"align="center"><tdwidth="300"valign="middle"align="center"><fontcolor="#0000FF"face="微軟雅黑"size=5px><ahref="guanlimain.jsp">首頁</a></font></td><tdwidth="300"valign="middle"align="center"><fontcolor="#00FF00"face="微軟雅黑"size=5px><ahref="admin.jsp">學(xué)生信息管理</a></font></td><tdwidth="300"valign="middle"align="center"><fontcolor="#CC0000"face="微軟雅黑"size=5px><ahref="glnote.jsp">班級(jí)論壇管理</a></font></td><tdwidth="300"valign="middle"align="center"><fontcolor=#174cacface="微軟雅黑"size=5px><ahref="vote_gl.jsp">班委選舉管理</a></font></td><tdwidth="300"valign="middle"align="center"></td><tdwidth="200"valign="middle"align="center"><ahref="Logout"target=_top>注銷</a></td></tr></table></div></div><title>班級(jí)論壇</title> <metahttp-equiv="pragma"content="no-cache"> <metahttp-equiv="cache-control"content="no-cache"> <metahttp-equiv="expires"content="0"> <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"> <metahttp-equiv="description"content="Thisismypage"></head><body><%@includefile="/gl_top.jsp"%><% HttpSessionsession1=request.getSession(); //取得會(huì)話對(duì)象中保存的驗(yàn)證碼,由驗(yàn)證碼生成Servlet存入 Stringuserid=(String)session1.getAttribute("userid"); System.out.println("userid:"+userid); %><%@tagliburi="/jsp/jstl/core"prefix="c"%><p>歡迎來到班級(jí)論壇</p><sql:setDataSourcedriver="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost/cityoa"user="root"password="abc123"var="noteData"scope="request"/><sql:querysql="select*fromnotes"dataSource="${noteData}"var="notelist"scope="request"><%System.out.println("userid1:"+userid);%></sql:query><hr/> <c:forEachvar="row"items="${notelist.rows}"> <table> <tr> ${row.id}:<br> <td><divstyle="border:solid1pxblack;"><p>${row.note}</p> </div> 發(fā)表時(shí)間:<fmt:formatDatevalue="${row.dates}"type="both" pattern="yy年MM月dd日"/> <br> </td> <td><ahref="delnote_gl.jsp?id=${row.id}">刪除</a></td> </tr> </table> </c:forEach></body></html><%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%><%@tagliburi="/jsp/jstl/core"prefix="c"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><basehref="<%=basePath%>"><title>MyJSP'grxx.jsp'startingpage</title><divstyle="margin:10px008px;width:100%;"><h1>修改個(gè)人信息</h1><hr/><p></p><ahref="mylist.jsp">查詢個(gè)人信息</a><br/><ahref="xuigaimm.jsp">修改密碼</a><br/><ahref="xuigaixx.jsp">修改信息</a></div></td><td><divstyle="margin:10px008px;width:100%;"></div></td></tr></table></body></html><%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><%@tagliburi="/jsp/jstl/core"prefix="c"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>班級(jí)網(wǎng)站</title> <metahttp-equiv="pragma"content="no-cache"> <metahttp-equiv="cache-control"content="no-cache"> <metahttp-equiv="expires"content="0"> <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"> <metahttp-equiv="description"content="Thisismypage"> </head><body><%@includefile="/gl_top.jsp"%><tablewidth="100%"border="0"><tr><td><divstyle="margin:10px008px;width:100%;"><%@pagecontentType="text/html;charset=GBK"%><%@pagelanguage="java"import="java.sql.*"%><%@tagliburi="/jsp/jstl/core"prefix="c"%><jsp:useBeanid="connDbBean"scope="application"class="javaee.ch04.VoteConn"/><head> <title>班委候選名單</title></head><%ResultSetrs;rs=connDbBean.executeQuery("select*fromvote");%><bodybgcolor="#FFFFFF"><%@includefile="/top.jsp"%><center><h2><fontcolor="#0000ff">請(qǐng)您投票:</font></h2><formaction="vote.jsp"method="post"><Tableborder="1"bgcolor="#00FFFF"><%while(rs.next()){%><TR><TD><inputtype="radio"name="type"value=<%=rs.getString("id")%>><ahref="mylist_vote.jsp?username=<%=rs.getString("note")%>"><%=rs.getString("note")%></a></TD></TR> <%} rs.close(); %><TRalign="center"><TD><Inputtype="submit"value="投票"></TD></TR><TR><TD><Ahref="details.jsp">查看投票</A></TD></TR></Table></form></center></body></html><%@pagelanguage="java"import="java.util.*"pageEncoding="gb2312"%><%@tagliburi="/jsp/jstl/core"prefix="c"%><%@tagliburi="/jsp/jstl/fmt"prefix="fmt"%><%@tagliburi="/jsp/jstl/sql"prefix="sql"%><%@tagliburi="/jsp/jstl/xml"prefix="x"%><%@tagliburi="/jsp/jstl/functions"prefix="fn"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>班級(jí)論壇</title> <metahttp-equiv="pragma"content="no-cache"> <metahttp-equiv="cache-control"content="no-cache"> <metahttp-equiv="expires"content="0"> <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"> <metahttp-equiv="description"content="Thisismypage"></head><body><% HttpSessionsession1=request.getSession(); //取得會(huì)話對(duì)象中保存的驗(yàn)證碼,由驗(yàn)證碼生成Servlet存入 Stringuserid=(String)session1.getAttribute("userid"); System.out.println("userid:"+userid); %><%@includefile="/top.jsp"%><p>歡迎來到班級(jí)論壇</p><sql:setDataSourcedriver="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost/cityoa"user="root"password="abc123"var="noteData"scope="request"/><sql:querysql="selectnote,dates,NAMEfromnotes,userinfo1whereidlikeUSERID"dataSource="${noteData}"var="notelist"scope="request"><%System.out.println("userid1:"+userid);%></sql:query><hr/> <c:forEachvar="row"items="${notelist.rows}"> ${row.NAME}:<br><divstyle="border:solid1pxblack;"><p>${row.note}</p> </div> 發(fā)表時(shí)間:<fmt:formatDatevalue="${row.dates}"type="both" pattern="yy年MM月dd日"/> <br> </c:forEach><hr/><p>我要發(fā)表:</p> <formmethod="post"action="addnote.jsp">rs=connDbBean.executeQuery("select*fromvote");%><h2><fontcolor="#0000ff">請(qǐng)您投票:</font></h2><formaction="vote.jsp"method="post"><Tableborder="1"bgcolor="#00FFFF"><%while(rs.next()){%><TR><TD><inputtype="radio"name="type"value=<%=rs.getString("id")%>><ahref="mylist_vote.jsp?username=<%=rs.getString("not
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度城市公共交通車輛運(yùn)營管理合同3篇
- 2025年度柴油市場(chǎng)分析與預(yù)測(cè)服務(wù)合同范本4篇
- 專業(yè)設(shè)備銷售協(xié)議模板集(2024版)版
- 2025年廠區(qū)綠化生態(tài)教育推廣與培訓(xùn)服務(wù)協(xié)議4篇
- 2024年起重機(jī)研發(fā)與購銷合作項(xiàng)目合同范本3篇
- 二零二四家居建材店員工勞動(dòng)合同模板3篇
- 2025年度智能機(jī)器人技術(shù)研發(fā)合作協(xié)議4篇
- 2024版企業(yè)技術(shù)改造借款的合同范本
- 二零二五版醫(yī)療設(shè)備采購與租賃合同范本3篇
- 2024年04月吉林銀行總行投資銀行部2024年社會(huì)招考1名負(fù)責(zé)人筆試歷年參考題庫附帶答案詳解
- GB/T 6913-2008鍋爐用水和冷卻水分析方法磷酸鹽的測(cè)定
- GB/T 18717.2-2002用于機(jī)械安全的人類工效學(xué)設(shè)計(jì)第2部分:人體局部進(jìn)入機(jī)械的開口尺寸確定原則
- 教案:第三章 公共管理職能(《公共管理學(xué)》課程)
- 中國文化概論(第三版)全套課件
- 117-鋼結(jié)構(gòu)工程質(zhì)量常見問題與管控措施
- SHS5230三星指紋鎖中文說明書
- 諾和關(guān)懷俱樂部對(duì)外介紹
- 保定市縣級(jí)地圖PPT可編輯矢量行政區(qū)劃(河北省)
- 新蘇教版科學(xué)六年級(jí)下冊(cè)全冊(cè)教案(含反思)
- 供方注冊(cè)指南-ZTE
- 真心英雄合唱歌詞
評(píng)論
0/150
提交評(píng)論