Web编程技术补考模拟测验(B卷)

上传人:E**** 文档编号:83063339 上传时间:2022-04-30 格式:DOCX 页数:13 大小:36.27KB
收藏 版权申诉 举报 下载
Web编程技术补考模拟测验(B卷)_第1页
第1页 / 共13页
Web编程技术补考模拟测验(B卷)_第2页
第2页 / 共13页
Web编程技术补考模拟测验(B卷)_第3页
第3页 / 共13页
资源描述:

《Web编程技术补考模拟测验(B卷)》由会员分享,可在线阅读,更多相关《Web编程技术补考模拟测验(B卷)(13页珍藏版)》请在装配图网上搜索。

1、Web 编程技术模拟试卷(B 卷)一、填空题20 分 (20*1)1.请写出常用的Web 服务器:IIS 、 Apache、 Tomcat.2.请写出常用的常用的Web 编辑工具: Dreamweaver 、Editplue 、 Eclipse3.JDBC 、 JSP、 DAO 英文全称分别是:JDBC:Java Data Base ConnectivingJSP:Java Server Page DAO : Data Access Object4.JSP 的内置对象有out、 request、 response、 session、 application5.连接数据库的四要素:数据库驱动、数

2、据库的URL 、数据库的用户名、数据库的密码二、选择题15 分 (15*1)1.下面那个控件的属性设置成相同可以达到各个控件共同一组的效果(B)A id B name C type D value2.下面哪一个JSP 的注释,客户端是可见的(A)AB/ C D/*.*/3. 不与下列哪些操作指令配合使用(D)A B C D4.下列哪一个不是JDBC 的接口 (D)A DriverManager B ConnectionC StatementD Preparement5.jsp 执行过程: Jsp- java- class-网页 f 分别是以下哪个顺序过程?(A)A. 翻译 -编译 -执行 B.

3、 翻译 -执行 -编译C.编译 -翻译 -执行D.执行 -编译 -翻译6.如下选项有哪一个是jsp 表达式? AA. B. C.x=3y+1 D.7.Javascript 连接 js 文件方法 script languae= “ javascript ” src=“ _A_”8.下面哪一个不是单标签?(D)A. B. C. D.9.当点击提交后跳转客户端通过 (A) 访问服务器A IE B我的电脑C 网上邻居D 回收站10.关闭 sql 数据库的顺序是(A)A 先关闭结果集再关闭操作最后关闭连接B 先关闭连接再关闭操作最后关闭结果集C 先关闭操作再关闭结果集最后关闭连接D 先关闭结果集再关闭连

4、接最后关闭操作11.下列说法正确的是(A)A.jsp 不一定是jsp 开发的B.Jsp 一定是 jsp 开发的C.Jsp 编译后生成java 后缀D.Jsp 运行后生成java 后缀12.第三方 jar 文件保存在哪一个目录下?()A WEB ROOTB WEB ROOT/WEB-INFCWEB ROOT/WEB-INF/lib D WEB ROOT/WEB-INF/classes1/1313.123456 在页面中显示的效果是(B)A 123456 B*C.password:123456 D123456*14可以利用 request 对象的哪个方法获取客户端的表单信息?AA ) respon

5、se.getParameter()B )response.outParameter()C) response.writeParameter()D) response.handlerParameter()15 用于在表单中插入一个下拉菜单,它需与哪个标记配合使用?DA ) B )C)D ) 三、单句代码解释题20 分(10*2)1. 点击嘉庚图片超连接到集美大学网页: 表单以 post 的方式提交到 a1.html 提交的时候并调用 javascript 的 check 函数检查3.setTimeOut( “ a()” ,5000)alert(“xxxx ”)定时onload 网页加载延时500

6、0 毫秒调用a 函数执行a 方法并弹出警告框提示4.var time = new Date() 。 获取当前日期页面加载时使光标停留在myform 表单的name 控件位置聚焦6. response.setHeader(refresh,2) 。out.println(new Date() 。/ 每隔 2 秒自动刷新显示时间7./隐藏域 看不见页面上本身用户不能在其中输入用来预设某些要传送的信息。8./ 设置编码防止乱码。 / 传递参数返回值类型为Stringrequest.getParameterValues()。 / 获得参数所包含的值一组多个值。 / 设置属性防盗链保存用户名session

7、.getAttribute() 。 / 取得属性session.isNew() 。/ 判断是否是一个新的用户session.invalidate() 。 / 使 session 失效注销退出application.getAttribute() 。 /返回对象获取application.setAttribute() 。 / 添加对象设置四、简答题10 分(5*2)1.简单介绍下JSP 的开发环境如何搭建以及JSP 程序如何运行?1.安装 JDK 添加环境变量2.安装 Tomcat 在 IE 中输入或 http:/ 本机ip:8080 或 http:/localhost:8080 )。检验是否启动

8、成功出现猫,若此时浏览器中显示Tomcat的欢迎和管理画面,即表示服务器安装和启动成功。3.安装 SQL Server2005 4. 安装MyEclipse7.5 关于 Tomcat 服务器虚拟目录的配置打开 Tomcat 的安装目录,进入 conf/server.xml ,在 上方加入 2. 与 有什么区别? (B 卷) 包含静态的内容先包含后处理动态包含先处理后包含3. 与 response.sendRedirect()有什么区别? (B 卷 ) URL不变,服务端跳转无条件跳转之后代码不再执行释放资源传递参数response.sendRedirect() URL 地址改变,客户端跳转有条

9、件跳转不能保存 request 的属性2/13URL 重写传递参数4.Page、 request、 session 与 application 的区别是什么?生成期、作用范围又有何不同?在一个页面范围内:page在一次服务器请求范围内:request在一次会话范围内:session在一个应用服务器范围内:application5.DAO 数据访问接口的用途是什么?前台显示与后台逻辑操作分离, JSP 页面的功能就是将DAO 返回的结果进行输出。6.Servlet 的开发步骤servlet 的核心代码写在哪?在哪里注册?一般情况下,主要用到doGet 和 doPost 方法。 web.xml 注

10、册7.在这学期开发过程遇到什么问题,你又是如何解决的?A 卷考过五、程序解释题10 分(5*2)1.分析程序运行结果原网页 a1.jsp:程序一:“aaa”)。“bbb”)。运行结果: aaa URL 地址: a1.jsp 属于服务端跳转程序二:“aaa”)。response.sendRedirect(“a2.jsp”)。“bbb”)。运行结果: aaa bbb URL 地址: a2.jsp 属于客户端跳转:includeDemo.jsp 中的 :Include.jsp :include.jsp:运行结果:includeDemo.jsp 中的 :100include.jsp:103.scope

11、 四种范围:page,只在当前页有效,适用于操作数据库调用两次结果显示request,属性只保存在一次服务器跳转中,使用 才可调用 1 次刷新递增session,属性保存在一次会话中,适用于开发购物车等无论怎么刷新也不会重新声明数字递增application ,属性公有,此对象在整个服务器只实例化一次只创建一次3/13六、程序改写题5 分(5*1)1.B 卷中代码改写 效率提高题目给代码 表单提交改写成 Java Bean 源代码: 姓名: 年龄: 改写 姓名: 年龄: 七、设计题10 分 (10*1)1.编写一个可以打印出九九乘法表的JSP网页,要求对齐和一定的修饰(B 卷要求用表达式)%f

12、or(int i=1 。 i%for(int j=1 。 j*= 。   。 4/13A 卷考过的四部曲第一个字段  。   。   。 第二个字段   。   。   。  。   。%=%= 数据库操作成功!%新闻一级标题发布系统实现对数据库的增删改查前台调用jsp DB6 配合 jsp构造容器创建容器扔进容器取出showFirstTitle.jspID 号 新闻分类 创建者 创建时间 %NewsFirstTitleDB6 first=new NewsFirstTitleDB6()。List list=firs

13、t.getAllFirstLevelTitleList()。if(list.size()!=0)for(int i=0 。 iNewsFirstTitleDB6.javapackage jmu。import jmu.FirstLevelTitle。public class NewsFirstTitleDB6 /* 从数据库中取出所有新闻一级标题,并封装在集合中返回*/publicList getAllFirstLevelTitleList() List list = new ArrayList()。Connection dbConnection = null 。PreparedStatemen

14、t pStatement = null。ResultSet res = null 。try dbConnection = ConnectionManager.getConnection() 。String strSql = select * from FirstLevelTitle order by CreateTime desc。pStatement = dbConnection.prepareStatement(strSql) 。res = pStatement.executeQuery()。while (res.next() int id = res.getInt(id) 。String

15、 title = res.getString(2) 。String creator = res.getString(Creator) 。/Date time = res.getDate(CreatTime) 。FirstLevelTitle fTitle = new FirstLevelTitle(id, title, creator, time)。list.add(fTitle) 。 catch (SQLException sqlE) sqlE.printStackTrace() 。 finally ConnectionManager.closeResultSet(res) 。 Connec

16、tionManager.closeStatement(pStatement) 。 ConnectionManager.closeConnection(dbConnection) 。6/13return list 。addFirstTitle.jsp 标题名: 注意:发布前请认真检查输入的标题是否正确保存页面saveFirstTitle.jsp 0) request.getRequestDispatcher(success.jsp).forward(request,response)。 else request.getRequestDispatcher(error.jsp).forward(re

17、quest,response) 。%FirstLevelTitleDbOpreation.javapublic int insertOneRecord(FirstLevelTitle fTitle) int result = 0 。Connection con = null 。7/13PreparedStatement pStatement = null。try SimpleDateFormat HMFromat = new SimpleDateFormat(yyyy-MM-ddhh:mm:ss) 。String strCurrentTime = HMFromat.format( new Da

18、te()。con = ConnectionManager .getConnection() 。String strSql =insert into FirstLevelTitle values(?,?,?,?)。pStatement = con.prepareStatement(strSql)。pStatement.setInt(1, getNewId() 。pStatement.setString(2, fTitle.getTitleName() 。pStatement.setString(3, fTitle.getCreator() 。pStatement.setString(4, str

19、CurrentTime) 。result = pStatement.executeUpdate()。catch (SQLException sqlE) sqlE.printStackTrace() 。finally ConnectionManager.closeStatement(pStatement) 。ConnectionManager.closeConnection(con) 。return result。删除一级标题:delFirstTitle.jsppublic void deleteFirstLevelTitle(int firstTitleId )Connection dbCon

20、nection = null 。PreparedStatement pStatementS = null。PreparedStatement pStatementF = null。/ResultSet res = null 。try dbConnection = ConnectionManager.getConnection() 。String delSecondSql = delete from SecondLevelTitle where ParentTitle=?。pStatementS = dbConnection.prepareStatement(delSecondSql) 。pSt

21、atementS.setInt(1, firstTitleId) 。pStatementS.executeUpdate()。String delFirstSql=delete from FirstLevelTitle where id=?。pStatementF = dbConnection.prepareStatement(delFirstSql) 。pStatementF.setInt(1, firstTitleId) 。pStatementF.executeUpdate()。catch(Exception e)8/13e.printStackTrace() 。更新一级标题:onclick

22、=”window.open(updateFirstTitle.jsp?id=)”public void updateFirstTitle(int firstLevelId,String titlename,String creator) Connection con = null 。PreparedStatement pStatement = null。try con = ConnectionManager.getConnection() 。String strSql = update FirstLevelTitle set TitleName = ? ,Creator = ? where I

23、d = ?。pStatement = con.prepareStatement(strSql)。pStatement.setString(1, titlename)。pStatement.setString(2, creator)。pStatement.setInt(3, firstLevelId) 。int row = pStatement.executeUpdate() 。成功更新了 +row+ 行数据 !) 。 catch (SQLException sqlE) sqlE.printStackTrace() 。 finally ConnectionManager.closeStateme

24、nt(pStatement)。ConnectionManager.closeConnection(con) 。2.DAO 技术的开发步骤DAO 由以下几部分组成:DatabaseConnection:专门负责数据库的打开与关闭操作的类。VO :主要由属性、setter、getter 方法组成, VO 类中的属性与表中的字段相对应,每一个VO 类的对象都表示表中的每一条记录。DAO :主要定义操作的接口,定义一系列数据库的原子操作,如增加、修改、删除、按ID 查询等。 Impl : DAO 接口的真实实现类,完成具体的数据库操作,但是不负责数据库的打开和关闭。Vo 类:。9/13public c

25、lass Product /商品 IDprotected int productID 。/商品编号protected String serialNumber 。/商品名字protected String name。/商品品牌protected String brand 。/商品型号protected String model 。/商品价格protected double price 。/商品的图片路径protected String picture 。/商品描述protected String description 。/商品无参构造public Product() super()。/商品有参

26、构造public Product(String serialNumber, String name, String brand,String model, double price, String picture, String description) super()。this.serialNumber = serialNumber 。this.name = name。this.brand = brand 。this.model = model 。this.price = price 。this.picture = picture 。this.description = descriptio

27、n 。public int getProductID() return productID 。public void setProductID(int productID) this.productID = productID 。public String getSerialNumber() return serialNumber 。public void setSerialNumber(String serialNumber) 10/13this.serialNumber = serialNumber 。public String getName() return name。public v

28、oid setName(String name) this.name = name。public String getBrand() return brand。public void setBrand(String brand) this.brand = brand 。public String getModel() return model 。public void setModel(String model) this.model = model 。public double getPrice() return price 。public void setPrice(double pric

29、e) this.price = price 。public String getPicture() return picture 。public void setPicture(String picture) this.picture = picture 。public String getDescription() return description 。public void setDescription(String description) this.description = description 。Impl :定义接口。11/13public interface IProduct

30、DAO public ArrayList getAllNextGoods(int page,int pageCount) throws Exception。public ArrayList getAllGoods()throws Exception。public int getPages(int pageCount)throws Exception 。public Product getOneGood(int pid)throws Exception。public boolean addNew(Product product)throws Exception。public boolean up

31、dateOneGood(Product product)throws Exception 。public boolean delGood(int pid)throws Exception。public boolean goodsDel(int pids)throws Exception。Dao.impl :具体实现类。public class ProductDAOImpl implements IProductDAO /* 添加新商品* 参数:新商品信息的类对象*/public boolean addNew(Product product) throws Exception boolean r

32、esult=false。Connection con=null 。PreparedStatement pstmt=null 。try con=ConnectionManager.getCon() 。pstmt=con.prepareStatement(insert into PRODUCT values(?,?,?,?,?,?,?) 。pstmt.setString(1, product.getSerialNumber() 。pstmt.setString(2, product.getName() 。pstmt.setString(3, product.getBrand() 。pstmt.se

33、tString(4, product.getModel() 。pstmt.setDouble(5, product.getPrice() 。pstmt.setString(6, product.getPicture() 。pstmt.setString(7, product.getDescription() 。int count=pstmt.executeUpdate() 。if (count=1) result=true。finally12/13ConnectionManager.closeAll(con, pstmt, null)。return result。/ TODO Auto-gen

34、erated method stub前台 addProduct.jsp %request.setCharacterEncoding(GB18030) 。String num=(String)request.getParameter(serialNumber) 。String name=(String)request.getParameter(name) 。String brand=(String)request.getParameter(brand) 。String model=(String)request.getParameter(model) 。String picture=(Strin

35、g)request.getParameter(picture) 。double price=Double.parseDouble(request.getParameter(price) 。String desciption=(String)request.getParameter(description) 。ProductDAOImpl pDao=new ProductDAOImpl()。Product product=new Product() 。product.setName(name)。product.setBrand(brand) 。product.setModel(model) 。product.setSerialNumber(num) 。product.setPicture(picture) 。product.setDescription(desciption) 。product.setPrice(price) 。if(pDao.addNew(product)out.print(alert( 添加新商品成功!) 。 location=manageProduct.jsp) 。elseout.print(alert( 添加新商品失败!) 。 location=addProduct.jsp) 。%13/13

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!