日期:2014-05-18  浏览次数:20752 次

求教web数据库操作问题
D:\Tomcat   5.0\webapps\sqlserver下有index.html
D:\Tomcat   5.0\webapps\sqlserver\WEB-INF下有web.xml
D:\Tomcat   5.0\webapps\sqlserver\WEB-INF\classes下有AddBook.java和AddBook.class
其中:
----------------------------------
index.html内容如下:
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN ">
<HTML>
<HEAD>
<TITLE>   添加图书到SQL   Server数据库 </TITLE>
<META   NAME= "Generator "   CONTENT= "EditPlus ">
<META   NAME= "Author "   CONTENT= " ">
<META   NAME= "Keywords "   CONTENT= " ">
<META   NAME= "Description "   CONTENT= " ">
</HEAD>

<BODY>
<h2> <B> 在下面输入图书信息后提交 </b> </h2> <Br>
<form   method= "post "   action= "/sqlserver/servlet/AddBook ">
图书名称: <input   type= "text "   name= "bookname "> <Br>
图书作者: <input   type= "text "   name= "bookauthor "> <Br>
图书价格: <input   type= "text "   name= "bookprice "> <Br>
图书介绍: <textarea   name= "bookintroduce "   rows=6> </textarea> <Br>
<input   type= "submit "   value= "提交 "> <input   type= "reset "   value= "重填 ">
</form>
</BODY>
</HTML>

-----------------------------------
web.xml内容如下:
<?xml   version= "1.0 "   encoding= "ISO-8859-1 "?>
<!DOCTYPE   web-app
        PUBLIC   "-//Sun   Microsystems,   Inc.//DTD   Web   Application   2.3//EN "
        "http://java.sun.com/dtd/web-app_2_3.dtd ">
<web-app>
    <display-name> Welcome   to   Tomcat </display-name>
    <description>
          Welcome   to   Tomcat
    </description>
<!--   JSPC   servlet   mappings   start   -->

<!--   实例6-1   -->
<servlet>  
<servlet-name> AddBook </servlet-name>  
<display-name> AddBook </display-name>  
<description> A   test   Servlet </description>  
<servlet-class> AddBook </servlet-class>  
</servlet>  

<servlet-mapping>  
<servlet-name> AddBook </servlet-name>  
<url-pattern> /AddBook </url-pattern>  
</servlet-mapping>

--------------------------

AddBook内容如下:
/*   AddBook.java添加一本图书到数据库   */
//导入相关的包
import   java.sql.*;
import   java.io.*;
import   javax.servlet.*;
import   javax.servlet.http.*;

public   class   AddBook   extends   HttpServlet
{

//定义servlet的post方法
public   void   doPost(HttpServletRequest   request,HttpServletResponse   response)   throws   ServletException, jdk1.5,jdk1.6,jdk1.7的区别和联系是什么?该怎么解决