實驗四答案、_第1頁
實驗四答案、_第2頁
實驗四答案、_第3頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、Web 實驗報告學號:姓名:陳波專業(yè):信管1201實驗目的:1、掌握內(nèi)置對象的用法2、掌握JSP基本概念。3、掌握session對象的應用編程;4、掌握application對象的應用編程;5、熟悉初步的JSP代碼片段應用編程6、掌握WEB項目中集合類如何應用于頁面。 實驗內(nèi)容:練習1.完成購物車功能Login.jsp<% request ? setCharacterEncoding("UTF-8");%>vform action="Login.jsp" method= "post n>請輸入姓名:<input type

2、="text" name ="name f,x/input><br>請輸入密碼 :<input type = "password" name = "pass" value=>v/i nput><br><input type = "submit" value ="登錄"<input id = "canceL" type= ”reset,f value ="取消千 OPW<%if(request

3、.getParameter(” name")!=null)&&(request.getParameter( pass")!=nu II)( sessi on. setAttribute(" name"(request.getParameter(" name");sessi on. setAttribute("pass"(request.getParameter("pass");%>vjsp:forward page = "k/etcowe.jsp nx/jsp:f

4、orward><%) %>目 loginjsp I 2 Teacherinfo.java 2 ManageTeachers.jc回秒 o ca I h o st:8080/g o uwu/l o g i n J s p 請輸入姓名L請輸入密碼:Welcome.jsp<% request.setcharacterE ncodi ng("UTF-8");Stri ng logi nn ame =n ull;if (sessi on. getAttribute(" name")!=n ull)logi nn ame = sessio n

5、.getAttribute(" name").toStri ng();%>歡迎你!<%=logi nn ame %><br><script>fun cti on e()locati on .href="list.jsp"setTimeout ("e()", 3000);/ 設置等待時間 </script>'F .la_|ZZT/'H) log in .jsp I JJ Teacheri nfojava Mgn ageTea?<凰 & http:/loc

6、alhost:8080/gouwu/login.jsp歡迎你!陳皓if (listName! =null)(Stri ng listName = request.getParameterValues("choice");for (int i =0;i<listNameength;i+)(session.setAttribute(String .valueOf(i)listNamei); %><pxa href= "choiceList.jsp"> 查看購物車 </a>I 園 loginjsp 2) Teacherinf

7、ojava 2) ManageTeachersjava I 昌 teacherjsp _園 teacJ B 秒 oca I hList.jsp<%request.setCharacterE ncodi ng("UTF-S") ;%> 請選擇需要購買的水果:<p> <form i<in put<in put<in put<in put<in put<in put<in put</form> <%method = "post" actio n = "List.

8、jsp" type namehecktoxe type =" checkbox" type ="checkbox" type checkbox" valuevalu n arrtype checkboxe nampe ="dhecbox" valu type =namen amenam e""submit" ="choiceIIe valu e valu="choice加入購物車"=''芒果'芒果="葡萄" &g

9、t; 葡萄="哈密瓜"哈密 瓜="香蕉" > 香蕉=''火龍果'、> 火n ame="submit">ost:8080/g ou wu/l ist.js p請選擇需要購買的水果:1杳看購物車Choicelist.jspv%page import="java. utiL. %><%request.setCharacterE ncodi ng("UTF-8");Enu merati on< Stri ng> enu mlist= sessio

10、n.getAttributeNames();%>購物車中的寶貝為:<P><%while (enumlist.hasMoreElements()Stri ng key = enu mlist. nextEleme nt();String value = sessio n.getAttribute(key).toStri ng();if(! key. equals ("pass" )&&! key. equalsC name")!out. println( value);%>昌_loginjsp J Teacherinfo

11、.java T ManageTeachers.java I S tea B http:/localhost:8080/gouwu/choicelist.jsp購物車中的寶貝為:香蕉葡萄芒果狙回重新選搔練習2.完成留言板功能:包括留言信息提交。查看留言板等。MsgBoard.jspvform action="save.jsp" method="post">請輸入姓名:<input type="text" name="name ”x/inputxbr>請輸入標題:<input type = "t

12、ext" name ="msgtitLe" ></inputxbr> 請輸入留言: vtextarea cols=60 rows=10name="msg" style="background-color:bute"><!- 請輸入留言喲! -></textarea><in put n ame = "en ter" type="submit"value ="提交留言"</form>jS MsgBoard

13、.jsp save.jsp 3 In sert title here g詹 http:/localhost:8080/liuyan/MsgBoard.jsp請輸入姓名:請輸入標題:< !-請輸入留言喲!-> I函§言請輸入留言:save.jsp<% request.setcharacterE ncodi ng("UTF-8");Stri ng n ame = request.getParameter(” name");String msgtitle = request.getParameter("msgtitle")

14、;String msg = request.getParameter("msg");Message m = new Message。;m.setMsg(msg);m.setMsgtitle(msgtitle);m.setName( name);m.setTim e(new Date().toStri ng();ArrayList<Message> list=n ull;if (applicati on. getAttribute("msg")=nu II)list = new ArrayList<Message>();elseli

15、st=(ArrayList<Message>)(applicati on .getAttribute("msg");list.add(m);applicatio n.setAttribute("msg"list);out.println("您的留言已經(jīng)提交!” ;%<pxa cef="MsgBoarcl.jsp"> 繼續(xù)留言 </a><pxa hreA"show.jsp"> 查看留言 </a>U| MsgBoard.jsp 百 save.jsp

16、In sert title here S3 & http:/localhost:8080/liuyan/MsgBoard.jsp請輸入姓名:陳皓請輸入標題:雙11到了哦I快把你女票的銀行卡凍結(jié)了5 MsgBoardjsp _園_save.jsp Insert title here U <) 畫秒 htt p:/l o ca I h o st:8080/1i uy a n/s ave.j s p您的留言已經(jīng)提交!繼續(xù)留言查看留言show.jspv%request.setCharacterE ncodi ng("UTF-8");%><% ArrayLi

17、st<Message> list=(ArrayList<Message>)(applicati on. getAttribute("msg");%> <% for(int i=O;i<list.size();i+)(Message m=list.get(i);Stri ng n ame=m.getName();String title=m.getMsgtitle();Stri ng msg=m.getMsg();String time=m.getTime();%>vtable border="2" bord

18、ercolor="#000000 f,><tr><th> 序號 </th><th> 姓名 </th><th> 標題 </th><th> 留言 </th><th> 時間 </th>v/tr><tr><td> 第 <%=i+l %個</td><td><%= n ame%x/td><tdx%=title%x/td><td>v%=msg%x/td><td>v%=time%x/td

溫馨提示

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

評論

0/150

提交評論