这是为什么啊?
org.apache.jasper.JasperException: Exception in JSP: /process.jsp:30
27:
28: Context ctx=new InitialContext();
29: DataSource ds=(DataSource)ctx.lookup("java:comp/env/guest");
30: Connection conn=ds.getConnection();
31:
32: PreparedStatement pstmt=conn.prepareStatement(
33: "insert into guestbook(gst_user,gst_title,gst_content,gst_ip) values(?,?,?,?)");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.process_jsp._jspService(process_jsp.java:143)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
org.apache.jsp.process_jsp._jspService(process_jsp.java:124)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
-------------------原代码如下-----------------------
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*,javax.sql.*,javax.naming.*" %>
<%@ include file="util.jsp" %>
<%
request.setCharacterEncoding("gb2312");
String name=request.getParameter("name");
String title=request.getParameter("title");
String content=request.getParameter("content");
if(null==name || null==title || null==content)
{
response.sendRedirect("index.jsp");
return;
}
name=toHtml(name.trim());
title=toHtml(title.trim());
if(name.equals("") || title.equals(""))
{
response.sendRedirect("say.html");
return;
}
content=toHtml(content.trim());
String fromIP=request.getRemoteAddr();
Context ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env/guest");
Connection conn=ds.getConnection();
PreparedStatement pstmt=conn.prepareStatement(
"insert into guestbook(gst_user,gst_title,gst_content,gst_ip) values(?,?,?,?)");
pstmt.setString(1,name);
pstmt.setString(2,title);
pstmt.setString(3,content);
pstmt.setString(4,fromIP);
pstmt.executeUpdate();
pstmt.close();
conn.close();
response.sendRedirect("index.jsp");
%>
------------------配置信息如下----------------
<?xml version="1.0" encoding="UTF-8"?>
<Context
docBase="F:/SmallItem/guestbook/guest"
reloadable="true">
<Resource
auth="Container"
name="guest"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
password=""
maxIdle="30"
maxWait="100000"
username="root"
url="jdbc:mysql://localhost:3306/test?autoReconnect=true"
maxActive="100"/>
</Context>