web程序设计报告_第1页
web程序设计报告_第2页
web程序设计报告_第3页
web程序设计报告_第4页
web程序设计报告_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Web程序设计实验报告PAGE1Web程序设计实验报告院别计算机与通信工程学院专业计算机科学与技术班级学号姓名成绩2013年12月27完成三个html页面,三个页面之间可以通过链接互相访问,自由的设置其中的控件,使用一个css表单来美化这三个页面。<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>index.html</title> <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="thisismypage"><metahttp-equiv="content-type"content="text/html;charset=UTF-8"><!--<linkrel="stylesheet"type="text/css"href="./styles.css">--><linkrel="stylesheet"type="text/css"href="mycss.css"></head><body><h1>Sunset</h1><p><ahref="1.html">link1</a></br><ahref="2.html">link2</a></p></body></html><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>1.html</title> <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="thisismypage"><metahttp-equiv="content-type"content="text/html;charset=UTF-8"><linkrel="stylesheet"type="text/css"href="mycss.css"><!--<linkrel="stylesheet"type="text/css"href="./styles.css">--></head><body><h1>ThisismyHTMLpage1.<br></h1></body></html>2.html<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title>2.html</title> <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="thisismypage"><metahttp-equiv="content-type"content="text/html;charset=UTF-8"><linkrel="stylesheet"type="text/css"href="mycss.css"><!--<linkrel="stylesheet"type="text/css"href="./styles.css">--></head><body><h1>ThisismyHTMLpage2.<br></h1></body></html>Mycss.css@CHARSET"UTF-8";h1{color:red;background-color:gray;text-align:left;font-size:58pt;}body{color:blue;background-image:url(Sunset.jpg);}

熟悉DOM的原理和使用【实验内容】在刚才建立的index.html页面添加一个删除按钮,做一个基于DOM的js函数,每次点击删除按钮就会将刚才生成的一个控件删除。【实验内容】将一个字符串使用doGet方法提交给Servlet,Servlet统计其中每个字母出现的次数,然后打印在页面上<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><basehref="<%=basePath%>"><title>MyJSP'index.jsp'startingpage</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"> <!-- <linkrel="stylesheet"type="text/css"href="styles.css"> --></head><body>ThisismyJSPpage.<br><center><formmethod="get"action="servlet/login"><p>学号:<inputtype="TextField"name="id"value=""></p><p>姓名:<inputtype="TextField"name="name"value=""></p><p>字符串:<inputtype="TextField"name="str"value=""><p><inputtype="submit"name="Submit"value="签到"><inputtype="reset"value="重写"></form></center></body></html>【实验名称】使用servlet和JDBC访问数据库【实验内容】源代码:Index.jsp:

<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><basehref="<%=basePath%>"><title>MyJSP'index.jsp'startingpage</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"> <!-- <linkrel="stylesheet"type="text/css"href="styles.css"> --></head><body><formmethod="get"action="servlet/QueryServlet2"><fieldset><legendalign="center">JDBC注册</legend><center><p>用户名:<inputtype="text"size="20"name="user"></p><p>密   码: <inputtype="text"size="20"name="password"></p><p><inputtype="submit"value="注册"name="button2"></p></center></fieldset></form><formmethod="get"action="servlet/QueryServlet"><fieldset><legendalign="center">JDBC登录</legend><center><p>用户名:<inputtype="text"size="20"name="user1"></p><p>密   码: <inputtype="text"size="20"name="password1"></p><p><inputtype="submit"value="登录"name="button1">   </p></center></fieldset></form></body></html>QueryServlet.javapackageneuq.dzxx;importjava.io.IOException;importjava.io.PrintWriter;importjava.sql.ResultSet;importjava.sql.SQLException;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;publicclassQueryServletextendsHttpServlet{ /** *Constructoroftheobject. */ privateDataOperatorDO; publicQueryServlet(){ super(); } /** *Destructionoftheservlet.<br> */ publicvoiddestroy(){ super.destroy();//Justputs"destroy"stringinlog //Putyourcodehere } /** *ThedoGetmethodoftheservlet.<br> * *Thismethodiscalledwhenaformhasitstagvaluemethodequalstoget. * *@paramrequesttherequestsendbytheclienttotheserver *@paramresponsetheresponsesendbytheservertotheclient *@throwsServletExceptionifanerroroccurred *@throwsIOExceptionifanerroroccurred */ publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ this.doPost(request,response); } /** *ThedoPostmethodoftheservlet.<br> * *Thismethodiscalledwhenaformhasitstagvaluemethodequalstopost. * *@paramrequesttherequestsendbytheclienttotheserver *@paramresponsetheresponsesendbytheservertotheclient *@throwsServletExceptionifanerroroccurred *@throwsIOExceptionifanerroroccurred */ publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ Stringuser1=request.getParameter("user1"); Stringpassword1=request.getParameter("password1"); Stringprice=""; //Stringprice="noprice"; try{ ResultSetrs=DO.query("selectpasswordfromInfowherename='"+user1+"';"); if(rs.next()){ price=rs.getString("password"); } }catch(SQLExceptione){ //TODOAuto-generatedcatchblock e.printStackTrace(); }if(price==password1){ response.setContentType("text/html"); PrintWriterout=response.getWriter(); out .println("<!DOCTYPEHTMLPUBLIC\"-//W3C//DTDHTML4.01Transitional//EN\">"); out.println("<HTML>"); out.println("<HEAD><TITLE>AServlet</TITLE></HEAD>"); out.println("<BODY>"); out.print("passwordiscorrect"); out.println("</BODY>"); out.println("</HTML>"); out.flush(); out.close();} } /** *Initializationoftheservlet.<br> * *@throwsServletExceptionifanerroroccure */ publicvoidinit()throwsServletException{ }}QueryServlet2.javapackageneuq.dzxx;importjava.io.IOException;importjava.io.PrintWriter;importjava.sql.ResultSet;importjava.sql.SQLException;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;publicclassQueryServlet2extendsHttpServlet{ /** *Constructoroftheobject. */ privateDataOperatorDO2; publicQueryServlet2(){ super(); } /** *Destructionoftheservlet.<br> */ publicvoiddestroy(){ super.destroy();//Justputs"destroy"stringinlog //Putyourcodehere } /** *TheDO2Getmethodoftheservlet.<br> * *Thismethodiscalledwhenaformhasitstagvaluemethodequalstoget. * *@paramrequesttherequestsendbytheclienttotheserver *@paramresponsetheresponsesendbytheservertotheclient *@throwsServletExceptionifanerroroccurred *@throwsIOExceptionifanerroroccurred */ publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ this.doPost(request,response); } /** *TheDO2Postmethodoftheservlet.<br> * *Thismethodiscalledwhenaformhasitstagvaluemethodequalstopost. * *@paramrequesttherequestsendbytheclienttotheserver *@paramresponsetheresponsesendbytheservertotheclient *@throwsServletExceptionifanerroroccurred *@throwsIOExceptionifanerroroccurred */ publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ Stringuser=request.getParameter("user"); Stringpassword=request.getParameter("password"); //Stringprice="noprice"; try{ DO2.insert("inser

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论