预 习 报 告

实验题目:图书借阅网站的实现——图书信息

预习内容:

  1. Servlet的概述

Servlet 是使用Java 语言编写的运行在服务器端的程序。狭义的 Servlet 是指Java 语言实现的一个接口,广义的Servlet是指任何实现了这个Servlet接口的类,一般情况下,人们将Servlet理解为后者。Servlet 主要用于处理客户端传来的 HTTP 请求,并返回一个响应,它能够处理的请求有 doGet()和doPost()等方法。

  1. JSP的特征

⑴跨平台性 ⑵业务代码相分离性 ⑶组件重用性 ⑷预编译性

  1. JavaBean的概述

JavaBean 是 Java 开发语言中一个可以重复使用的软件组件,它本质上就是一个Java类。

  1. JDBC常用的API的介绍

JDBC API主要位于java.sql包中,该包定义了一系列访问数据库的接口和类。

  1. MVC的模型

模型(Model)负责管理应用程序的业务数据、定义访问控制以及修改这些数据的业务规则。当模型的状态发生改变时,它会通知视图发生改变,并为视图提供查询模型状态的方法。

  1. DAO的概述

DAO(Data Access Object)数据访问对象是一个面向对象的数据库接口

实验目的与要求(及主要实验仪器、设备):

1、掌握Servlet的基本特性、生命周期和编程方式;

2、掌握JSP的基本特性和编程方式;

3、掌握JavaBean的基本特性和编程方式;;

4、掌握MVC和DAO设计模式的编程特性;

5、使用MVC和DAO设计模式设计图书借阅网站中图书信息的功能。

本次实验采用的主要设备:自带电脑。

实验原理(方法与与原理分析):

  1. navigation.jsp 管理员导航条界面
  2. banner.jsp: 头部界面
  3. copyright.jsp: 版权界面
  4. booktype.java  图书类型实体类
  5. bookinfo.java  图书信息实体类
  6. booktype_queryall.jsp 图书类型设置界面
  7. booktype_add.jsp 图书类型添加界面
  8. booktype_update.jsp 图书类型修改界面
  9. bookInfo_queryall.jsp  图书信息设置界面
  10. bookInfo_add.jsp  图书信息添加界面
  11. bookInfo_update.jsp  图书信息修改界面
  12. BookTypeAdd Servlet.java 图书类型添加功能控制器类
  13. BookInfoAdd Servlet.java 图书信息添加功能控制器类
  14. BookTypeQueryAllServlet.java 图书类型功能控制器类
  15. BookInfoQueryAllServlet.java 图书信息功能控制器类
  16. BookTypeUpdateServlet.java  图书类型修改功能控制器类
  17. BookInfoUpdateServlet.java  图书信息修改功能控制器类
  18. BookTypeDeleteServlet.java  图书类型删除功能控制器类
  19. BookInfoDeleteServlet.java  图书信息删除功能控制器类
  20. BookTypeDAO.java  图书类型功能接口类
  21. bookInfoDAO.java  图书信息功能接口类
  22. bookInfoDAOImpl.java:图书信息功能实现类
  23. bookTypeDAOImpl.java:图书类型功能实现类
  24. DAOFactory.java 工厂类
  25. DBConnection.java:数据库连接类
  26. web.xml 配置文件

实验步骤(程序代码与实验过程):

1.BookInfo.java
package vo;
public class BookInfo {
int bookid;
String bookname;
int booktypeid;String author;String pubname;String isbn;double price;String casename;int nownumber;int total;String booktypename;public int getBookid() {return bookid;}public void setBookid(int bookid) {this.bookid = bookid;}public String getBookname() {return bookname;}public void setBookname(String bookname) {this.bookname = bookname;}public int getBooktypeid() {return booktypeid;}public void setBooktypeid(int booktypeid) {this.booktypeid = booktypeid;}public String getAuthor() {return author;}public void setAuthor(String author) {this.author = author;}public String getPubname() {return pubname;}public void setPubname(String pubname) {this.pubname = pubname;}public String getIsbn() {return isbn;}public void setIsbn(String isbn) {this.isbn = isbn;}public double getPrice() {return price;}public void setPrice(double price) {this.price = price;}public String getCasename() {return casename;}public void setCasename(String casename) {this.casename = casename;}public int getNownumber() {return nownumber;}public void setNownumber(int nownumber) {this.nownumber = nownumber;}public int getTotal() {return total;}public void setTotal(int total) {this.total = total;}public String getBooktypename() {return booktypename;}public void setBooktypename(String booktypename) {this.booktypename = booktypename;}
}
2.booktype.java
private   int booktypeid;
private   String  booktypename;
public int getBooktypeid() {
return booktypeid;
}
public void setBooktypeid(int booktypeid) {
this.booktypeid = booktypeid;
}
public String getBooktypename() {
return booktypename;
}
public void setBooktypename(String booktypename) {
this.booktypename = booktypename;
}
3.bookinfo_add.jsp
<body>
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="510" valign="top" style="padding:5px;"><table width="98%" height="487"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:图书管理 &gt; 图书管理 &gt; 添加图书信息 &gt;&gt;&gt;</td>
</tr>
<tr>
<td align="center" valign="top"><table width="100%" height="493"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="BookInfoAddServlet">
<table width="600" height="432"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="center">图书编号:</td>
<td height="39"><input name="bookid" type="text" id="bookid" size="50">
* </td>
</tr>
<tr>
<td align="center">图书名称:</td>
<td height="39"><input name="bookname" type="text" id="bookname" size="50">
* </td>
</tr>
<tr>
<td align="center">图书类型:</td>
<td>
<select name="booktypeid" class="wenbenkuang" id="booktypeid">
<%
List<BookType> list=(List<BookType>)session.getAttribute("allbooktype");
for(int i=0;i<list.size();i++){
BookType booktype=list.get(i);
%>
<option value="<%=booktype.getBooktypeid()%>"><%=booktype.getBooktypename()%></option>
<%}%>
</select>
</td>
</tr>
<tr>
<td align="center">作者:</td>
<td><input name="author" type="text"  id="author" size="40"></td>
</tr>
<tr>
<td align="center">出版社:</td>
<td>
<select name="pubname" class="wenbenkuang" id="pubname">
<option value="清华大学出版社">清华大学出版社</option>
<option value="人民邮电出版社">人民邮电出版社</option>
<option value="北京大学出版社">北京大学出版社</option>
<option value="北京理工出版社">北京理工出版社</option>
</select>
</td>
</tr>
<tr>
<td align="center">ISBN:</td>
<td><input name="isbn" type="text" id="isbn"> * </td>
</tr>
<tr>
<td align="center">价格:</td>
<td><input name="price" type="text" id="price">(元) * </td>
</tr>
<tr>
<td align="center">书架:</td>
<td>
<select name="casename" class="wenbenkuang" id="casename">
<option value="TP">TP</option>
<option value="CM">CM</option>
<option value="CM">IO</option>
</select>
</tr>
<tr>
<td align="center">现存量:</td>
<td><input name="nownumber" type="text" id="nownumber">(本) * </td>
</tr>
<tr>
<td align="center">库存量:</td>
<td><input name="total" type="text" id="total">(本) * </td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td><input name="Submit" type="submit" class="btn_grey" value="保存" onClick="return check(form1)">
&nbsp;
<input name="Submit2" type="button" class="btn_grey" value="返回" onClick="history.back()"></td>
</tr>
</table>
</form>
</td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table><%@ include file="copyright.jsp"%></td>
</tr>
</table>
</body>
4.bookinfo_update.jsp
<body>
<%@include file="banner.jsp"%>
<%@include file="navigation.jsp"%>
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="510" valign="top" style="padding:5px;"><table width="98%" height="487"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:图书管理 &gt; 图书管理 &gt; 修改图书信息 &gt;&gt;&gt;</td>
</tr>
<tr>
<td align="center" valign="top"><table width="100%" height="493"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="BookInfoUpdateServlet">
<table width="600" height="432"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="center">图书名称:
<input name="bookid" type="hidden" size="50" value="<%=request.getParameter("bookid")%>">
</td>
<td height="39">
<input name="bookname" type="text"  id="bookname"  size="60" value="<%=new String(java.net.URLDecoder.decode(request.getParameter("bookname"),"GB18030").getBytes("ISO-8859-1"))%>">
</td>
</tr>
<tr>
<td align="center">图书类型:</td>
<td><select name="booktypeid"  >
<%
List<BookType> allbooktype=(List<BookType>)request.getSession().getAttribute("allbooktype");
String booktypename=new String(java.net.URLDecoder.decode(request.getParameter("booktypename"),"GB18030").getBytes("ISO-8859-1"));
int booktypeid=Integer.parseInt(request.getParameter("booktypeid"));
for(int i=0;i<allbooktype.size();i++){
BookType booktype=allbooktype.get(i);
if(booktypeid==booktype.getBooktypeid()){
%>
<option value="<%=booktypeid%>" selected="selected"><%=booktype.getBooktypename()%></option>
<%
}else{
%>
<option value="<%=booktype.getBooktypeid()%>"><%=booktype.getBooktypename()%></option>
<%}%>
<%}%>
</select>
</td>
</tr>
<tr>
<td align="center">作者:</td>
<td><input name="author" type="text"  id="author" size="40"  value="<%=new String(java.net.URLDecoder.decode(request.getParameter("author"),"GB18030").getBytes("ISO-8859-1"))%>"></td>
</tr>
<tr>
<td align="center">出版社:</td>
<td>
<select name="pubname" class="wenbenkuang">
<option value="清华大学出版社">清华大学出版社</option>               <option value="人民邮电出版社">人民邮电出版社</option>               <option value="北京大学出版社">北京大学出版社</option>                <option value="北京理工出版社">北京理工出版社</option>                </select>
</td>
</tr>
<tr>
<td align="center">ISBN:</td>
<td><input name="isbn" type="text" id="isbn" value="<%=new String(java.net.URLDecoder.decode(request.getParameter("isbn"),"GB18030").getBytes("ISO-8859-1"))%>">  </td>
</tr>
<tr>
<td align="center">价格:</td>
<td><input name="price"type="text"id="price"value="<%=request.getParameter("price")%>">(元) * </td>
</tr>
<tr>
<td align="center">现存量:</td>
<td><input name="nownumber" type="text" id="nownumber"  value="<%=request.getParameter("nownumber")%>">(本) * </td>
</tr>
<tr>
<td align="center">库存量:</td>
<td><input name="total" type="text" id="total" value="<%=request.getParameter("bookid")%>">(本) * </td>
</tr>
<tr>
<td align="center">书架:</td>
<td><select name="casename" class="wenbenkuang" id="casename" >                 <option value="TP">TP</option>
<option value="CM">CM</option>
<option value="CM">IO</option>
</select>
</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td><input name="Submit" type="submit" class="btn_grey" value="保存" onClick="return check(form1)">
&nbsp;
<input name="Submit2" type="button" class="btn_grey" value="返回" onClick="history.back()"></td>
</tr>
</table>  </form>   </td>
</tr></table></td>
</tr>
</table></td>
</tr></table><%@ include file="copyright.jsp"%></td>
</tr></table>
</body>
5.bookinfo_delete.jsp
<body>
<%@include file="banner.jsp"%>
<%@include file="navigation.jsp"%>
<%  bookinfo bookinfo=(bookinfo)session.getAttribute("bookinfo");        %>  <table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">  <tr>
<td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="510" valign="top" style="padding:5px;"><table width="98%" height="487"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:图书管理 &gt; 图书管理 &gt; 修改图书信息 &gt;&gt;&gt;</td>
</tr>
<tr>
<td align="center" valign="top">
<table width="100%" height="493"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="BookInfoUpdateServlet">
<table width="600" height="432"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="center">图书名称:
<input name="bookid" type="hidden" size="50" value="<%=bookinfo.getBookid()%>">
</td>
<td height="39">
<input name="bookname" type="text"  id="bookname"  size="60" value="<%=bookinfo.getBookname()%>" readonly>*
</td>
</tr>
<tr>
<td align="center">图书类型:
</td>
<td>
<select name="booktypename" id="booktypename" >
<option value="
<%=bookinfo.getBooktypename()%>">
<%=bookinfo.getBooktypename()%>
</option>
<% List
<booktype> allbooktype=(List
<booktype>)session.getAttribute("allbooktype");
for(int i=0;i
<allbooktype.size();i++){              booktype booktype=allbooktype.get(i);%>
<option value="
<%=booktype.getBooktypename()%>">
<%=booktype.getBooktypename()%>
</option>
<%} %>
</select>
</td>
</tr>
<tr>
<td align="center">作者:
</td>
<td>
<input name="author" type="text"  id="author" size="40"  value="
<%=bookinfo.getAuthor()%>">
</td>
</tr>
<tr>
<td align="center">出版社:
</td>
<td>
<select name="pubname" class="wenbenkuang">
<option value="清华大学出版社">清华大学出版社
</option>
<option value="人民邮电出版社">人民邮电出版社
</option>
<option value="北京大学出版社">北京大学出版社
</option>
<option value="北京理工出版社">北京理工出版社
</option>
</select>
</td>
</tr>
<tr>
<td align="center">ISBN:
</td>
<td>
<input name="isbn" type="text" id="isbn" value="
<%=bookinfo.getIsbn()%>">
</td>
</tr>
<tr>
<td align="center">价格:
</td>
<td>
<input name="price" type="text" id="price" value="
<%=bookinfo.getPrice()%>">(元) *
</td>
</tr>
<tr>
<td align="center">现存量:
</td>
<td>
<input name="nownumber" type="text" id="nownumber"  value="
<%=bookinfo.getNownumber()%>">(本) *
</td>
</tr>
<tr>
<td align="center">库存量:
</td>
<td>
<input name="total" type="text" id="total"  value="
<%=bookinfo.getTotal()%>">(本) *
</td>
</tr>
<tr>
<td align="center">书架:
</td>
<td>
<select name="casename" class="wenbenkuang" id="casename" >
<option value="TP"
<%if("TP".equals(bookinfo.getCasename())){%>selected
<%}%>>TP
</option>
<option value="CM"
<%if("CM".equals(bookinfo.getCasename())){%>selected
<%}%>>CM
</option>
<option value="IO"
<%if("IO".equals(bookinfo.getCasename())){%>selected
<%}%>>IO
</option>
</select>
</td>
</tr>
<tr>
<td align="center">&nbsp;
</td>
<td>
<input name="Submit" type="submit" class="btn_grey" value="保存" onClick="return check(form1)">        &nbsp;
<input name="Submit2" type="button" class="btn_grey" value="返回" onClick="history.back()">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%@ include file="copyright.jsp"%>
</td>
</tr>
</table>
</body>
6.Bookinfo_queryall.jsp
<%@include file="banner.jsp" %>
<%@include file="navigation.jsp" %>
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="385" valign="top" bgcolor="#FFFFFF"><table width="99%" height="341"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="341" valign="top" style="padding:5px;"><table width="98%" height="295"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:系统设置 &gt; 图书设置 &gt;&gt;&gt;</td>
</tr>
<tr>
<td height="273" align="center" valign="top">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="BookInfoTypeQueryAllServleta" >添加图书信息</a> </td>
</tr>
</table>
<table width="100%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolordark="#F6B83B" bordercolorlight="#FFFFFF">
<tr align="center" bgcolor="#e3F4F7">
<td width="5%"    bgcolor="#F9D16B" >图书编号</td>
<td width="10%" bgcolor="#F9D16B">图书名称</td>
<td width="10%" bgcolor="#F9D16B">图书类型</td>
<td width="10%" bgcolor="#F9D16B">作者</td>
<td width="10%" bgcolor="#F9D16B">出版社</td>
<td width="10%" bgcolor="#F9D16B">ISBN</td>
<td width="10%" bgcolor="#F9D16B">价格</td>
<td width="5%" bgcolor="#F9D16B">书架</td>
<td width="10%" bgcolor="#F9D16B" >现存量</td>
<td width="10%" bgcolor="#F9D16B">总库存</td>
<td width="5%" bgcolor="#F9D16B">修改</td>
<td width="5%" bgcolor="#F9D16B">删除</td>
</tr>
<%List list=(List)request.getSession().getAttribute("allbookinfo");
for(int i=0;i<list.size();i++){
BookInfo bookinfo = (BookInfo)list.get(i);%>
<tr>
<td style="padding:5px;"><%=bookinfo.getBookid()%></td>
<td style="padding:5px;"><%= bookinfo.getBookname()%></td>
<td style="padding:5px;"><%=bookinfo.getBooktypename()%></td>
<td style="padding:5px;"><%=bookinfo.getAuthor()%></td>
<td style="padding:5px;"><%=bookinfo.getPubname()%></td>
<td style="padding:5px;"><%=bookinfo.getIsbn()%></td>
<td style="padding:5px;"><%=bookinfo.getPrice()%></td>
<td style="padding:5px;"><%=bookinfo.getCasename()%></td>
<td style="padding:5px;"><%=bookinfo.getNownumber()%></td>
<td style="padding:5px;"><%=bookinfo.getTotal()%></td>
<td align="center"><a href="BookInfoTypeQueryAllServlet?bookid=<%=bookinfo.getBookid()%>&bookname=<%=URLEncoder.encode(bookinfo.getBookname(),"gb18030")%>&booktypename=<%=URLEncoder.encode(bookinfo.getBooktypename(),"gb18030")%>&author=<%=URLEncoder.encode(bookinfo.getAuthor(),"gb18030")%>&pubname=<%=URLEncoder.encode(bookinfo.getPubname(),"gb18030")%>&isbn=<%=URLEncoder.encode(bookinfo.getIsbn(),"gb18030")%>&casename=<%=URLEncoder.encode(bookinfo.getCasename(),"gb18030")%>&price=<%=bookinfo.getPrice()%>&nownumber=<%=bookinfo.getNownumber()%>&total=<%=bookinfo.getTotal()%>&booktypeid=<%=bookinfo.getBooktypeid()%>">修改</a></td>
<td align="center"><a href="BookInfoDeleteServlet?bookid=<%=bookinfo.getBookid()%>" >删除</a></td>
</tr>
<%}%>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table><%@ include file="copyright.jsp"%></td>
</tr>
7.booktype_add.jsp
<table width="292" height="175" border="0" cellpadding="0" cellspacing="0" background="Images/subBG.jpg">
<tr>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="3%" height="25">&nbsp;</td>
<td width="94%">&nbsp;</td>
<td width="3%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><table width="100%" height="131"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="BookTypeAddServlet">
<table width="100%" height="114"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="74" align="center">图书类型编号:
<input name="booktypeid" type="text"><br>
图书类型名称:
<input name="booktypename" type="text"></td>
</tr>
<tr>
<td align="center" style="width: 177px; "><input name="Submit3" type="submit" class="btn_grey" value="保存">
&nbsp;
<input name="Submit22" type="button" class="btn_grey" value="关闭" onClick="window.close();"></td>8.booktype_update.jsp
<form name="form1" method="post" action="BookTypeUpdateServlet">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="50" align="center">  图书类型名称:
<%    List<booktype> updatebooktype=new ArrayList<booktype>();
updatebooktype=(List<booktype>)session.getAttribute("updatebooktype");
for(int i=0;i<updatebooktype.size();i++){
booktype  booktype=updatebooktype.get(i);
%>  <input name="booktypeid" type="hidden" value="<%=booktype.getBooktypeid() %>">
<input name="booktypename" type="text" value="<%=booktype.getBooktypename() %>"/>
<%
} %>
</td>
</tr>
<tr>
<td height="35" align="center"><input name="Submit" type="submit" class="btn_grey" value="保存">
&nbsp;
<input name="Submit2" type="reset" class="btn_grey" value="重置">
&nbsp;
<input name="Submit3" type="button" class="btn_grey" onClick="window.close()" value="关闭"></td>
</tr>
</table>
</form>
9.booktype_queryall.jsp
<body>
<%@include file="banner.jsp" %>
<%@include file="navigation.jsp" %>
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="385" valign="top" bgcolor="#FFFFFF">
<table width="99%" height="341"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="341" valign="top" style="padding:5px;">
<table width="98%" height="295"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:图书管理信息 &gt; 图书类型设置 &gt;&gt;&gt;
</td>
</tr>
<tr>
<td height="273" align="center" valign="top">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<a href="booktype_add.jsp" >添加图书类型信息
</a>
</td>
</tr>
</table>
<table width="91%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolordark="#F6B83B" bordercolorlight="#FFFFFF">
<tr align="center" bgcolor="#e3F4F7">
<td width="30%" bgcolor="#F9D16B">图书类型编号
</td>
<td width="40%" bgcolor="#F9D16B">图书类型名称
</td>
<td width="16%" bgcolor="#F9D16B">修改
</td>
<td width="14%" bgcolor="#F9D16B">删除
</td>
</tr>
<!-- 取值显示 allBookType(List) 会话  for——BookType——booktypeid  booktypename -->
<%    List
<booktype> allbooktype = (List
<booktype>) session.getAttribute("allbooktype");    for(int i=0;i
<allbooktype.size();i++){    booktype booktype=allbooktype.get(i); %>
<tr>
<td style="padding:5px;">
<%=booktype.getBooktypeid()%>
</td>
<!-- 显示 -->
<td style="padding:5px;">
<%=booktype.getBooktypename()%>
</td>
<td align="center">
<a href="BookTypeSearchServlet?booktypeid=
<%=booktype.getBooktypeid()%>">修改
</a>
</td>
<td align="center">
<a href="BookTypeDeleteServlet?booktypeid=
<%=booktype.getBooktypeid()%>">删除
</a>
</td>
</tr>
<%} %>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%@ include file="copyright.jsp"%>
</td>
</tr>
</table>
</body>
10.BookTypeAddServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContenttype("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
booktype booktype=new booktype();
booktype.setBooktypeid(Integer.parseInt(request.getParameter("booktypeid")));
booktype.setBooktypename(request.getParameter("booktypename"));
try {
if(DAOFactory.getBooktypeDAOInstance().doCreate(booktype)){
request.getRequestDispatcher("BooktypeQueryAllServlet").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
11.BookTypeUpdteServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
String booktypename = request.getParameter("booktypename");
int booktypeid = Integer.parseInt(request.getParameter("booktypeid"));
booktype booktype=new booktype();
booktype.setBooktypeid(booktypeid);
booktype.setBooktypename(booktypename);
try {
if(DAOFactory.getBookTypeDAOInstance().doUpdate(booktype)){
request.getRequestDispatcher("BookTypeQueryAllServlet").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}}12.BookTypeDeleteServlet.java
throws ServletException, IOException {
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
int booktypeid=Integer.parseInt(request.getParameter("booktypeid"));
try {
if(DAOFactory.getBookTypeDAOInstance().doDelete(booktypeid)){
request.getRequestDispatcher("BookTypeQueryAllServlet").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
13.BookTypeQueryAllServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb18030");
response.setContentType("text/html;charset=gb18030");
try {
List<booktype> allbooktype=DAOFactory.getBookTypeDAOInstance().findAllbooktype();
request.getSession().setAttribute("allbooktype", allbooktype);
request.getRequestDispatcher("booktype_queryall.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
14.BookInfoAddServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
booktype_add.jsp booktypeid booktypename,
bookinfo bookinfo=new bookinfo();              bookinfo.setBookid(Integer.parseInt(request.getParameter("bookid")));             bookinfo.setBookname(request.getParameter("bookname"));               bookinfo.setBooktypename(request.getParameter("booktypename"));               bookinfo.setAuthor(request.getParameter("author"));               bookinfo.setPubname(request.getParameter("pubname"));             bookinfo.setIsbn(request.getParameter("isbn"));               bookinfo.setPrice(Double.parseDouble(request.getParameter("price")));             bookinfo.setCasename(request.getParameter("casename"));               bookinfo.setNownumber(Integer.parseInt(request.getParameter("nownumber")));               bookinfo.setTotal(Integer.parseInt(request.getParameter("total")));
try {
if(DAOFactory.getBookInfoDAOInstance().doCreate(bookinfo)){
request.getRequestDispatcher("BookInfoQueryAllServlet").forward(request, response);
}
} catch (Exception e) {         e.printStackTrace();                }           }
this.doGet(request, response);
15.BookInfoUpdteServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");      //取值    设置vo        bookinfo bookinfo=new bookinfo();        bookinfo.setBookid(Integer.parseInt(request.getParameter("bookid")));        bookinfo.setBookname(request.getParameter("bookname"));        bookinfo.setBooktypename(request.getParameter("booktypename"));        //bookinfo.setBooktypeid(Integer.parseInt(request.getParameter("booktypename")));        bookinfo.setAuthor(request.getParameter("author"));        bookinfo.setPubname(request.getParameter("pubname"));        bookinfo.setIsbn(request.getParameter("isbn"));        bookinfo.setPrice(Double.parseDouble(request.getParameter("price")));        bookinfo.setCasename(request.getParameter("casename"));        bookinfo.setNownumber(Integer.parseInt(request.getParameter("nownumber")));        bookinfo.setTotal(Integer.parseInt(request.getParameter("total")));
try {
if(DAOFactory.getBookInfoDAOInstance().doUpdate(bookinfo)){
request.getRequestDispatcher("BookInfoQueryAllServlet").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}   }
8.BookInfoDeleteServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");      int bookid=Integer.parseInt(request.getParameter("bookid"));
try {
if(DAOFactory.getBookInfoDAOInstance().doDelete(bookid))
{
request.getRequestDispatcher("BookInfoQueryAllServlet").forward(request, response);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
16.BookInfoQueryAllServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
try {
List<bookinfo> allbookinfo=DAOFactory.getBookInfoDAOInstance().findAllbookinfo();
request.getSession().setAttribute("allbookinfo", allbookinfo);
List<booktype> allbooktype=DAOFactory.getBookTypeDAOInstance().findAllbooktype();
request.getSession().setAttribute("allbooktype", allbooktype);
request.getRequestDispatcher("bookinfo_queryall.jsp").forward(request, response);
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
17.Web.xml
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoAddServlet</servlet-name>
<servlet-class>servlet.BookInfoAddServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoQueryAllServlet</servlet-name>
<servlet-class>servlet.BookInfoQueryAllServlet</servlet-class>
</servlet>
<servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoDeleteServlet</servlet-name>
<servlet-class>servlet.BookInfoDeleteServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoUpdateServlet</servlet-name>
<servlet-class>servlet.BookInfoUpdateServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeAddServlet</servlet-name>
<servlet-class>servlet.BookTypeAddServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeQueryAllServlet</servlet-name>
<servlet-class>servlet.BookTypeQueryAllServlet</servlet-class>
</servlet>
<servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeDeleteServlet</servlet-name>
<servlet-class>servlet.BookTypeDeleteServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeUpdateServlet</servlet-name>
<servlet-class>servlet.BookTypeUpdateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BookInfoAddServlet</servlet-name>
<url-pattern>/BookInfoAddServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookInfoQueryAllServlet</servlet-name>
<url-pattern>/BookInfoQueryAllServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookInfoDeleteServlet</servlet-name>
<url-pattern>/BookInfoDeleteServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookInfoUpdateServlet</servlet-name>
<url-pattern>/BookInfoUpdateServlet</url-pattern></servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeAddServlet</servlet-name>
<url-pattern>/BookTypeAddServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeQueryAllServlet</servlet-name>
<url-pattern>/BookTypeQueryAllServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeDeleteServlet</servlet-name>
<url-pattern>/BookTypeDeleteServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeUpdateServlet</servlet-name>
<url-pattern>/BookTypeUpdateServlet</url-pattern></servlet-mapping>
18.BookTypeDAO.java
public  List<booktype> findAllbooktype() throws  Exception;
public boolean  doCreate(booktype  booktype)throws  Exception;
public boolean  doDelete(int  booktypeid)throws  Exception;
public boolean doUpdate(booktype booktype)throws Exception;
List<booktype> findupdate(int booktypeid) throws Exception;
19.BookInfoDAO.java
public  List<bookinfo> findAllbookinfo() throws  Exception;
public boolean  doCreate(bookinfo  bookinfo)throws  Exception;
public boolean doDelete(int bookid) throws Exception;
public boolean doUpdate(bookinfo bookinfo) throws Exception;
public bookinfo findbookinfo(int bookid) throws Exception;
20.BookTypeDAOImpl.java
public List<booktype> findAllbooktype() throws Exception {
List<booktype> allbooktype=new ArrayList<booktype>();
try{
String sql="select * from booktype";
conn=dbc.getConnection();
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next()){
booktype booktype=new booktype();
booktype.setBooktypeid(rs.getInt("booktypeid"));
booktype.setBooktypename(rs.getString("booktypename"));
allbooktype.add(booktype);
}
rs.close();
pstmt.close();
}
catch(Exception e){e.printStackTrace();}
finally{dbc.closed();
}
return allbooktype;
}
@Override
public boolean doCreate(booktype booktype) throws Exception {
try{
String sql="insert into booktype values(?,?)";
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1, booktype.getBooktypeid());
pstmt.setString(2, booktype.getBooktypename());
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}catch(Exception e){e.printStackTrace();}
finally{
dbc.closed();
}
return flag;
}
@Override
public boolean doDelete(int booktypeid) throws Exception {
try{
String sql="delete  from booktype where booktypeid=?";
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1,booktypeid);
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}catch(Exception e){}
finally{
dbc.closed();
}
return flag;
}
@Override
public List<booktype> findupdate(int booktypeid) throws Exception {
List<booktype> updatebooktype=new ArrayList<booktype>();
try{
String sql="select booktypeid,booktypename from booktype where booktypeid=?";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, booktypeid);
rs=pstmt.executeQuery();
while(rs.next()){
booktype booktype=new booktype();
booktype.setBooktypeid(rs.getInt("booktypeid"));
booktype.setBooktypename(rs.getString("booktypename"));
updatebooktype.add(booktype);
}
pstmt.close();
}catch(Exception e){
e.printStackTrace();
}finally{
dbc.closed();
}
return updatebooktype;
}
@Override
public boolean doUpdate(booktype booktype) throws Exception {
try{
String sql="update booktype set booktypename=? where booktypeid=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,booktype.getBooktypename());
pstmt.setInt(2, booktype.getBooktypeid());
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}
catch(Exception e){e.printStackTrace();}
finally{
dbc.closed();
}
return flag;
}
}
21.BookInfoDAOImpl.java
public class BookInfoDAOImpl implements BookInfoDAO
{   private PreparedStatement pstmt=null;
private ResultSet rs=null;
boolean flag=false;
DBConnection dbc=new DBConnection();
Connection conn=dbc.getConnection();
@Override  public List<bookinfo> findAllbookinfo() throws
Exception{  List<bookinfo> allbookinfo=new ArrayList<bookinfo>();
try{
String sql="select bookid,bookname,booktypename,author,pubname,isbn,price,casename,nownumber,total from bookinfo join booktype on bookinfo.booktypeid=booktype.booktypeid";
//conn=dbc.getConnection();
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next()){
bookinfo bookinfo=new bookinfo();
bookinfo.setBookid(rs.getInt("bookid"));
bookinfo.setBookname(rs.getString("bookname"));
bookinfo.setBooktypename(rs.getString("booktypename"));
bookinfo.setAuthor(rs.getString("author"));
bookinfo.setPubname(rs.getString("pubname"));
bookinfo.setIsbn(rs.getString("isbn"));
bookinfo.setPrice(rs.getDouble("price"));
bookinfo.setCasename(rs.getString("casename"));
bookinfo.setNownumber(rs.getInt("nownumber"));
bookinfo.setTotal(rs.getInt("total"));                allbookinfo.add(bookinfo);          }
rs.close();
pstmt.close();
}
catch(Exception e){e.printStackTrace();}
finally{dbc.closed();
}
return allbookinfo;
}   @Override
public boolean doCreate(bookinfo
bookinfo)throws
Exception {
// TODO Auto-generated method stub
try{
String sql="insert into bookinfo values(?,?,(select  booktypeid  from booktype where  booktypename=?),?,?,?,?,?,?,?)";
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1, bookinfo.getBookid());
pstmt.setString(2,bookinfo.getBookname());
pstmt.setString(3,bookinfo.getBooktypename());
pstmt.setString(4,bookinfo.getAuthor());
pstmt.setString(5,bookinfo.getPubname());
pstmt.setString(6,bookinfo.getIsbn());
pstmt.setDouble(7,bookinfo.getPrice());
pstmt.setString(8,bookinfo.getCasename());
pstmt.setInt(9,bookinfo.getNownumber());
pstmt.setInt(10,bookinfo.getTotal());
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}catch(Exception e)
{e.printStackTrace();}
finally{
dbc.closed();
}
return flag;
}   @Override  public boolean doDelete(int bookid) throws Exception
{
// TODO Auto-generated method stub
try {
String sql="delete from bookinfo where bookid=?";
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1, bookid);
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
} catch (Exception e) {
e.printStackTrace();
} finally{
dbc.closed();
}
return flag;
}   @Override
public boolean doUpdate(bookinfo bookinfo) throws Exception
{
// TODO Auto-generated method stub
try {
String sql="update bookinfo set bookname=?,booktypeid=(select booktypeid from booktype where booktypename=?),author=?,pubname=?,isbn=?,price=?,casename=?,nownumber=?,total=?  where bookid=?";           pstmt=conn.prepareStatement(sql);
pstmt.setString(1,bookinfo.getBookname());
pstmt.setString(2,bookinfo.getBooktypename());
pstmt.setString(3,bookinfo.getAuthor());
pstmt.setString(4,bookinfo.getPubname());
pstmt.setString(5,bookinfo.getIsbn());
pstmt.setDouble(6,bookinfo.getPrice());
pstmt.setString(7,bookinfo.getCasename());
pstmt.setInt(8,bookinfo.getNownumber());
pstmt.setInt(9,bookinfo.getTotal());
pstmt.setInt(10,bookinfo.getBookid());
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
} finally{
dbc.closed();
}
return flag;
}   @Override
public bookinfo findbookinfo(int bookid)  throws Exception
{
bookinfo bookinfo = new bookinfo();
try {
bookid,bookname,bookinfo.booktypeid,booktypename,author,pubname,isbn,price,casename,nownumber,total from bookinfo join booktype on bookinfo.booktypeid=booktype.booktypeid";
String sql="select bookinfo.*,booktype.* from bookinfo join booktype on bookinfo.booktypeid=booktype.booktypeid where bookid=?";
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1, bookid);
rs=pstmt.executeQuery();
while(rs.next()){
bookinfo.setBookid(rs.getInt("bookid"));
bookinfo.setBookname(rs.getString("bookname"));
bookinfo.setBooktypename(rs.getString("booktypename"));
bookinfo.setAuthor(rs.getString("author"));
bookinfo.setPubname(rs.getString("pubname"));
bookinfo.setIsbn(rs.getString("isbn"));
bookinfo.setPrice(rs.getFloat("price"));
bookinfo.setCasename(rs.getString("casename"));
bookinfo.setNownumber(rs.getInt("nownumber"));
bookinfo.setTotal(rs.getInt("total"));
}
pstmt.close();
rs.close();
} catch (Exception e) {
e.printStackTrace();
} finally{
dbc.closed();
}
return bookinfo;
}
22.DAOFactory.java
public static UsersDAO getUsersDAOInstance(){
return new UsersDAOImpl();
}
public static BookTypeDAO getBookTypeDAOInstance(){
return new BookTypeDAOImpl();
}
public static BookInfoDAO getBookInfoDAOInstance(){
return new BookInfoDAOImpl();
}

实验结果(数据分析与结论):

1.查看图书信息

2.添加图书信息

3.查看添加后的图书信息

4.修改图书信息

5.查看修改后的图书信息

6.查看删除后的图书信息

7.查看图书类型

8.添加图书类型

9.查看添加后的图书类型信息

10.修改图书类型信息

11.查看修改后的图书类型信息

11.查看删除后的图书类型信息

问题讨论:

1.问:出现NullPointException错误

答:

1.主要是因为使用请求转发的时候要获取一个还没有设置的会话造成的

2.由此我把跳转方式换为了重定向跳转,继而成功执行

2.问:出现严重: Parse error in application web.xml file at jndi:/localhost/BMSProject009/WEB-INF/web.xml 错误

答:经排查发现问题原因在web.xml里<servlet>里的<servlet-name>与<servlet-mapping>里的<servlet-name>名称不对称,经其修改后执行成功。

3.问:出现严重: Error getConfigured错误

答:

1.经过排查发现这个错误是出现于web.xml里;

2.出现原因是在创建与jsp文件相对应的servlet文件时有一个文件删除并创建时与web.xml不对应;

3.这个问题的解决方法为找到出现问题的servlet文件删除,然后在web.xml把对应的servlet的信息删除,最后重建对应的servlet文件,问题就解决了。

  1. 图书信息查看功能的实现

在主页点击图书设置得到图书设置界面,通过menu.JS界面的<a href=”BookInfoQueryAllServlet”>跳转到BookInfoQueryAllServlet,获取表单信息设置会话,通过工厂类DAOFctory中静态方法getBookinfoDAOInstance(),得到BookInfoDAOImpl实现类的对象,通过BookInfoDAO接口来执行数据库中的操作,然后使用vo中findAllbookinfo(),通过DBConnection,执行SQL语句,跳转到bookinfo_queryall.jsp,将查询到的图书信息显示出来。

  1. 图书信息添加功能的实现

在图书设置界面点击添加图书信息,通过bookinfo_queryall.jsp里的<a href="bookinfo_add.jsp" >语句,跳转到bookinfo_add.jsp,添加信息后通过<form>表单的action属性,跳转到BookInfoAddServlet控制器,在BookInfoAddServlet中使用 request 请求对象的 getParameter()方法获取表单bookid,author,booktypeid,bookname,casename,isbn,nownumber,price,pubname,total对应的信息的信息,设置vo后,执行BookInfoDAOImpl实现类的方法doCreate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookInfoQueryAllServlet,使用 List 方法获取图书信息,在设置会话跟踪后跳转到 bookinfo_queryall.jsp,最后展现出添加后的图书信息。

  1. 图书信息修改功能的实现

在图书设置界面点击修改,通过bookinfo_queryall.jsp里的href语句,跳转到BookInfoSearchServlet,在BookInfoSearchServlet中使用 request 请求对象的 getParameter()方法获取表单中bookid对应的信息,跳转到bookinfo_update.jsp,修改完成信息后通过<form>表单的action属性,跳转到BookInfoUpdateServlet控制器,BookInfoUpdateServlet中使用 request 请求对象的 getParameter()方法获取表单中使用 request 请求对象的 getParameter()方法获取表单bookid,author,booktypeid,bookname,casename,isbn,nownumber,price,pubname,total对应的信息的,设置vo后,执行BookInfoDAOImpl实现类的方法findupdate和doUpdate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookInfoQueryAllServlet,使用 List 方法获取图书信息,在设置会话跟踪后跳转到 bookinfo_queryall.jsp,最后展现出修改后的图书信息。

  1. 图书信息删除功能的实现

在图书设置界面点击删除,通过bookinfo_queryall.jsp里的href语句,跳转到BookInfoDeleteServlet,在BookInfoDeleteServlet中使用 request 请求对象的 getParameter()方法获取表单中bookid对应的信息,执行BookInfoDAOImpl实现类的方法doDelete,通过DBConnection,执行SQL语句,使用get()方法跳转到BookInfoQueryAllServlet,使用 List 方法获取图书信息,在设置会话跟踪后跳转到bookinfo_queryall.jsp,最后展现出删除后的图书信息。

  1. 图书类型查看功能的实现

在主页点击图书设置得到图书类型设置界面,通过menu.JS界面的<a href=”BookTypeQueryAllServlet”>跳转到BookTypeQueryAllServlet,获取表单信息设置会话,通过工厂类DAOFctory中静态方法getBooktypeDAOInstance(),得到BookTypeDAOImpl实现类的对象,通过BookTypeDAO接口来执行数据库中的操作,然后使用vo中findAllbooktype(),通过DBConnection,执行SQL语句,跳转到booktype_queryall.jsp,将查询到的图书类型信息显示出来。

  1. 图书类型添加功能的实现.

在图书类型设置界面点击添加图书类型,通过booktype_queryall.jsp里的<a href="booktype_add.jsp" >语句,跳转到booktype_add.jsp,添加信息后通过<form>表单的action属性,跳转到BookTypeAddServlet控制器,在BookTypeAddServlet中使用 request 请求对象的 getParameter()方法获取表单中booktypeid,booktypename对应的信息的信息,设置vo后,执行BookTypeDAOImpl实现类的方法doCreate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookTypeQueryAllServlet,使用 List 方法获取图书类型信息,在设置会话跟踪后跳转到 booktype_queryall.jsp,最后展现出添加后的图书类型信息。

  1. 图书类型修改功能的实现

在图书类型设置界面点击修改,通过booktype_queryall.jsp里的href语句,跳转到BookTypeSearchServlet,在BookTypeSearchServlet中使用 request 请求对象的 getParameter()方法获取表单中booktypeid对应的信息,跳转到booktype_update.jsp,修改完成信息后通过<form>表单的action属性,跳转到BookTypeUpdateServlet控制器,在BookTypeUpdateServlet中使用 request 请求对象的 getParameter()方法获取表单中使用 request 请求对象的 getParameter()方法获取表单中booktypeid,booktypename对应的信息的,设置vo后,执行BookTypeDAOImpl实现类的方法findupdate和doUpdate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookTypeQueryAllServlet,使用 List 方法获取图书类型信息,在设置会话跟踪后跳转到 booktype_queryall.jsp,最后展现出修改后的图书类型信息。

  1. 图书类型删除功能的实现

在图书类型设置界面点击删除,通过booktype_queryall.jsp里的href语句,跳转到BookTypeDeleteServlet,在BookTypeDeleteServlet中使用 request 请求对象的 getParameter()方法获取表单中booktypeid对应的信息,执行BookTypeDAOImpl实现类的方法doDelete,通过DBConnection,执行SQL语句,使用get()方法跳转到BookTypeQueryAllServlet,使用 List 方法获取图书类型信息,在设置会话跟踪后跳转到 booktype_queryall.jsp,最后展现出删除后的图书类型信息。

Java Web实验程序设计——图书借阅网站的实现——图书信息相关推荐

  1. Java web实验购物网站(IDEA开发环境,JavaScript,JSP,Servlet,MySql等)——实现购物车

    后面有资源包 Java web实验购物网站 实验要求 实验开发工具及使用技术 准备工作 完整项目目录结构 实验结果展示 实验步骤 小结 项目完整代码及数据库.SQL文件 实验要求 掌握静态HTML, ...

  2. Java web实验购物网站(IDEA开发环境,JavaScript,JSP,Servlet,jQuery,Ajax,MySql等)——实现购物车

    Java web实验购物网站 实验要求 实验开发工具及使用技术 准备工作 完整项目目录结构 实验结果展示 实验步骤 小结 项目完整代码及数据库.SQL文件 自学网站 2021.05.25补充 实验要求 ...

  3. Java Web项目性能测试 - JMeter测试网站吞吐量、反应时间百分比、流量

    Java Web项目性能测试 - JMeter测试网站吞吐量.反应时间百分比.流量 为了衡量.调整.完成Java Web项目的性能指标,满足客户.用户对性能的要求,保证项目上线后能正常运行,以及了解项 ...

  4. java javawebjsp图书借阅系统(jsp图书管理系统 )jsp书籍借阅系统

    java javawebjsp图书借阅系统(jsp图书管理系统 )jsp书籍借阅系统 protected void doGet(HttpServletRequest req, HttpServletR ...

  5. web实验3 简单水果网站模仿

    web实验3 简单水果网站模仿 需要实现效果如下 HTML部分 <!DOCTYPE html> <html lang="en"> <head>& ...

  6. java web应用程序设计填空题_Java Web程序设计题库答案

    Java Web Java Web程序设计题库 一.选择题 1.以下文件名后缀中,只有( C )不是静态网页的后缀. A..html B..htm C .JSP D..shtml 2.以下文件名后缀中 ...

  7. java web实验_javaweb实验报告

    javaweb实验报告 甘肃政法学院本科生实验报告(一)姓名:学院:计算机科学学院专业: 计算机科学与技术班级实验课程名称:实验日期:2012 年 04 月 9 日指导教师及职称实验成绩:开课时间:2 ...

  8. 项目总结——Java web之实现当当网网站

    Java web之实现当当网网站 运行环境:JDK1.8+tomcat8.4+MySQL5+servlet技术 源码结构 CategoryDAO.java package com.tarena.dao ...

  9. Java Jsp+Servlet+mysql实现的图书借阅系统(系统管理员/图书管理员/读者 功能:图书信息管理、图书借阅、我的借阅记录、管理图书、用户管理、反馈)

    博客目录 JSP图书借阅系统 主要功能点 实现功能截图 技术点总结 代码 写在最后 JSP图书借阅系统 随着社会经济的迅速发展和科学技术的全面进步以及计算机事业的飞速发展,以计算机科学与通信技术为基础 ...

最新文章

  1. 《linux c编程指南》学习手记5
  2. python奇数和_请问python如何判断奇偶数?
  3. mysql存储过程调试学习总结
  4. POJ 1742 Coins
  5. [Android] Android学习手记(二)
  6. 微课|玩转Python轻松过二级(2.1.3节):字符串与字节串简介
  7. 艾特肯法方程解matlab程序,牛顿迭代法matlab代码
  8. 人工智能大火能否烧开智能家居这锅水?
  9. vue中的浏览量_vue项目中使用百度统计
  10. Openssl(版本1.1.1)源码中的RSA加解密算法实现分析
  11. 题目汇总(ACWing)
  12. java计算机二级知识点、易错点整理(一)
  13. 【面试】小米公司嵌入式职位面试经验
  14. 净利环比缩水过半,Salesforce龙头地位不保?
  15. python基础学习笔记之数据基本类型:逻辑值
  16. html语言怎么让字横过来,css怎么让文字竖着排列?
  17. 初等矩阵左乘 右乘与初等变换
  18. cipher攻略(不断更新)
  19. 命名空间中不存在类型或命名空间名称。是否缺少程序集引用?
  20. 设计训练环境【ML-Agents 官方文档翻译(ML-Agent 1.9.1,Unity 2018-2020)】

热门文章

  1. Centos 7.5利用LVM实现动态扩容大小
  2. 期权激励的核心价值是:激励能人,一起和公司共同成长,实现利益共享,有钱大家一起赚(转)...
  3. 生物素化聚N-异丙基丙烯酰胺,Biotin-PNIPAM
  4. SQL Server sp_helpdb 改写
  5. 巴西队提前出线,预定大力神杯?数据分析告诉你,到底谁才是冠军
  6. JS精度问题 乘以10的N次方出现精度问题
  7. HDU4507吉哥系列故事――恨7不成妻
  8. 解决pyinstaller打包exe文件过大(菜鸟一刀切傻办法)
  9. springboot集成log4j2 附完整配置
  10. 实验二 小型局域网-ensp