JSP第6章实验报告.docx
《JSP第6章实验报告.docx》由会员分享,可在线阅读,更多相关《JSP第6章实验报告.docx(17页珍藏版)》请在冰豆网上搜索。
JSP第6章实验报告
肇庆学院计算机学院
JSP中使用数据库(实验)实验报告
实验名称
JSP中使用数据库(实验)
班级
姓名
学号
实验地点
日期
成绩
一、实验目的:
实验1的主要目的是让学生掌握使用JDBC查询数据库中表的记录。
实验2的目的是让学生掌握使用JDBC更新数据库中表的记录。
实验3的目的是掌握掌握使用JDBC删除数据库中表的记录。
二、实验环境:
WindowsXP操作系统的计算机,apache-tomcat-6.0.29(还要安装好jdk),Dreamweaver或者eclipse。
三、实验内容、步骤、实验结果与分析:
见附页
5、实验总结:
熟练掌握了怎么使用在JSP中使用数据库
实验1查询记录
编写一个JSP页面inputMess.jsp。
编写一个Tag文件FindBook.tag。
1)inputMess.jsp的具体要求
inputMess.jsp页面提供表单。
表单允许用户输入要查询的内容,以及选择针对该内容的查询条件,比如,输入“实用”,那么可以指定该内容是书名的一部分或作者姓名等。
inputMess.jsp页面查询条件提交给当前页面,当前页面调用FineBook.tag文件完成查询操作。
2)FindBook.tag的具体要求
FindBook.tag文件使用attribute指令获得inputMess.jsp页面传递过来的字段的查询条件,然后与数据源information建立连接、根据得到的查询条件查询bookForm表。
FindBook.tag文件使用variable指令将查询结果返回给inputMess.jsp页面。
JSP页面效果示例
inputMess.jsp的效果如图所示。
参考代码
可以按照实验要求,参考本代码编写代码。
1)JSP页面参考代码
inputMess.jsp
<%@pagecontentType="text/html;charset=GB2312"%>
<%@taglibtagdir="/WEB-INF/tags"prefix="findBook"%>
输入查询内容:
ISBN
书名
作者
出版社
出版时间
内容摘要
前方一致
后方一致
包含
<%
StringfindContent=request.getParameter("findContent");
Stringcondition=request.getParameter("condition");
StringfindMethod=request.getParameter("findMethod");
if(findContent==null){
findContent="";
}
if(condition==null){
condition="";
}
if(findMethod==null){
findMethod="";
}
%>
查询到的图书:
FindBookdataSource="information"
tableName="bookForm"
findContent="<%=findContent%>"
condition="<%=condition%>"
findMethod="<%=findMethod%>"/>
<%=giveResult%>