您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > 广州大学Web实验动态网页制作
广州大学学生实验报告开课学院及实验室:计算机科学与工程实验室4182016年6月1日学院计算机科学与教育软件学院年级/专业/班姓名学号实验课名称Web实验成绩一、实验目的1、配置JSP运行环境2、网上购物订单的制作3、简单购物车的实现二、实验内容实验1:配置JSP运行环境:下载并安装JDK6.0和Tomcat6.0作为运行JSP程序的实验环境(参见书上P177页的步骤)。实验2:网上购物订单的制作编写一个简单的JSP程序实现网上购物订单的基本功能:将客户在Shopping.html页面中输入的联系方式和邮寄地址等信息内容读取出来并显示在另一页面Shopping.jsp中。实验3:简单购物车的实现编写JSP程序实现购物车的基本功能,即向购物车中添加和删除商品,并给出购物车中的商品信息和总金额。三、实验设备PC、JetBrainsWebStorm10.0.3、JavaDevelopmentKit7.0、Tomcat7.0四、实验代码及结果1、网上购物订单的制作(1)实验代码//shopping.html!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN==Content-Typecontent=text/html;charset=utf-8/title实验三/title/headbodyp网上购物订单页面/pformname=frm1action=method=get实验项目名称动态网页制作指导老师inputtype=textname=text1value=用户姓名disabled=disabledinputtype=textname=namevalue=XXXbrinputtype=textname=text1value=联系电话disabled=disabledinputtype=text1name=televalue=88888888brinputtype=textname=text1value=邮寄地址disabled=disabledinputtype=text1name=addressvalue=广州市番禺区大学城brinputtype=submitinputtype=reset/form/body/html//shopping.jsp%$pageconteneType=text/html;charset=GB2312%%request.setCharacterEncoding(gb2312);%htmljsp:useBeanid=shopscope=pageclass=myBean.shopping/jsp:setPropertyname=shoppingproperty=*/bodybrfontsize=5face=宋体您的信息为:/fontbrhrtabletrtdwidth=200用户名/tdtdwidth=200联系电话/tdtdwidth=200邮寄地址/td/tr%Stringitem=shop.getItem();Intnumber=shop.getNumber();Out.println(trtdwidth=200+name+/td);Out.println(tdwidth=200+tele+/td);Out.println(tdwidth=200+address+/td/tr);%/table/bodyhtml//shopping.javaPackagemyBean;Publicclassshopping{publicStringname;publicinttele;publicStringaddress;publicvoidsetname(Stringname){name=name;}publicStringgetname(){returnname;}publicvoidsettele(Stringname){tele=name;}publicStringgettele(){returntele;}publicvoidsetaddress(Stringname){address=name;}publicStringgetaddress(){returnaddress;}}(2)实验结果2、简单购物车的实现(1)实验代码%@pagecontentType=text/html;charset=gb2312%%@pageimport=java.util.ArrayList%%!intm=0;intId=8888;ArrayListStringgoodslist=newArrayListString();ArrayListFloatpgoodslist=newArrayListFloat();ArrayListStringbuylist=newArrayListString();ArrayListFloatpbuylist=newArrayListFloat();ArrayListIntegernbuylist=newArrayListInteger();%%floattotal=0;%%if(Id==8888){goodslist.add(0,荔枝);goodslist.add(1,火龙果);goodslist.add(2,西瓜);goodslist.add(3,柚子);pgoodslist.add(0,8.8f);pgoodslist.add(1,9.6f);pgoodslist.add(2,5.2f);pgoodslist.add(3,4.8f);}%%session.setAttribute(goodslist,goodslist);session.setAttribute(pgoodslist,pgoodslist);%tableborder=1width=450rules=nonecellspacing=0cellpadding=0trheight=50tdcolspan=3align=center提供商品如下/td/trtd名称/tdtd价格(元/斤)/tdtd购买/td%session.getAttribute(goodslist);session.getAttribute(pgoodslist);%%if(goodslist==null||goodslist.size()==0){%trheight=100tdcolspan=3align=center没有商品可以显示/td/tr%}else{for(intm=0;mgoodslist.size();m++){%trheight=50align=centertd%=goodslist.get(m)%/tdtd%=pgoodslist.get(m)%/tdtdahref=index.jsp?id=%=m+1%购买/a/td/tr%}}%/table**************************************************************************tableborder=1width=450rules=nonecellspacing=0cellpadding=0tralign=centerheight=30bgcolor=lightgreytd名称/tdtd价格/tdtd数量/tdtd总价/tdtd移除/td/tr%Stringstr=request.getParameter(id);if(str==null||str.equals())str=0;try{Id=Integer.parseInt(str);}catch(NumberFormatExceptione){Id=0;e.printStackTrace();}%%if(Id==1){if(buylist.size()==0){buylist.add(0,goodslist.get(0));pbuylist.add(0,pgoodslist.get(0));nbuylist.add(0,1);}else{intk=0;for(;kbuylist.size();k++){if(buylist.get(k).equals(goodslist.get(0))){intw=nbuylist.get(k);nbuylist.set(k,w+1);break;}}if(k=buylist.size()){buylist.add(k,goodslist.get(0));pbuylist.add(k,pgoodslist.get(0));nbuylist.add(k,1);}}}if(Id==2){if(buylist.size()==0){buylist.add(0,goodslist.get(1));pbuylist.add(0,pgoodslist.get(1));nbuylist.add(0,1);}else{intk=0;for(;kbuylist.size();k++){if(buylist.get(k).equals(goodslist.get(1))){intw=nbuylist.get(k);nbuylist.set(k,w+1);break;}}if(k=buylist.size()){buylist.add(k,goodslist.get(1));pbuylist.add(k,pgoodslist.get(1));nbuylist.add(k,1);}}}if(Id==3){if(buylist.size()==0){buylist.add(0,goodslist.get(2));pbuylist.add(0,pgoodslist.get(2));nbuylist.add(0,1);}else{intk=0;for(;kbuylist.size();k++){if(buylist.get(k)==goodslist.get(2)){intw=nbuylist.get(k);nbuylist.set(k,w+1);break;}}if(k=buylist.size()){buylist.add(k,goodslist.get(2));pbuylist.add(k,pgoodslist.get(2));nbuylist.add(k,1);}}}if(Id==4){if(buylist.size()==0){buylist.add(0,goodslist.get(3));pbuylist.add(0,pgoodslist.get(3));nbuylist.add(0,1);}else{intk=0;for(;kbuylist.size();k++){if(buylist.get(k)==goodslist.get(3)){intw=nbuylist.get(k);nbuylist.set(k,w+1);break;}}if(k=buylist.size()){buylist.add(k,goodslist.get(3));pbuylist.add(k,pgoodslist.get(3));nbuylist.add(k,1);}}}if(Id==10){if(n
本文标题:广州大学Web实验动态网页制作
链接地址:https://www.777doc.com/doc-6322403 .html