[求助]jsp+javaBean除錯環境問題!

jeky發表於2006-12-16
請問在瀏覽器(tomcat5)裡執行jsp+javaBean,要怎麼配置環境變數啊,我剛學,在jb裡能執行,但是在瀏覽器裡就出現下面的錯誤啊,如果只是jsp就能除錯出來,但是現在我用javaBean就不行了,請大家幫幫忙好麼,謝謝了!
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /jekyweb/guestBook/index2.jsp(15,0) The value for the useBean class attribute jeky.db_conn is invalid.


目錄結構:
D:\web\jsp\Tomcat 5.0\webapps\ROOT\jekyweb\guestBook\index2.jsp

D:\web\jsp\Tomcat 5.0\webapps\ROOT\jekyweb\guestBook\jeky\db_conn.class

程式碼如下:
//index2.jsp
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.sql.*" language="java"%>
<html>
<head>
<title>
index
</title>
</head>

<body bgcolor="ffffff">
<h1>
JBuilder Generated JSP
</h1>
<br><br>
<jsp:useBean id="Conndb" scope="session" class="jeky.db_conn"/>
<%
Connection conn = Conndb.getConnection();
try{
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from guestBookData");
while(rs.next()){
out.println(rs.getString("userTime"));
}
rs.close();
stmt.close();
Conndb.close();
}catch(Exception e){e.printStackTrace();}

%>
<hr><br>

</body>
</html>



//db_conn.java

package jeky;

import java.io.*;
import javax.servlet.http.*;
import java.sql.*;

public class db_conn implements HttpSessionBindingListener {
public void valueBound(HttpSessionBindingEvent event){}//當變數加入時Session時自動執函式
public void valueUnbound(HttpSessionBindingEvent event){}//當變數關閉時Session時自動執函式
private Connection conn = null;
public db_conn() {//建立資料庫連線
BulidConnection();
}
private void BulidConnection(){//建立資料庫連線方法
try{
/*Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://210.38.196.123:1433;DatabaseName=guestBook";
String user="sa";
String password="jeky";
conn = DriverManager.getConnection(url,user,password);*/
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:guestBook","sa","jeky");
}catch(Exception ex){
System.out.print(ex.toString());
}
}
public Connection getConnection(){
if(conn == null)//如果conn為空,重新建立連線
BulidConnection();
return conn;
}
public void close(){
try{
conn.close();//關閉連線
conn = null;
}catch(SQLException ex){}
}
}


//我把db_conn.java在jb裡面編譯後把db_conn.class複製到
D:\web\jsp\Tomcat 5.0\webapps\ROOT\jekyweb\guestBook\jeky\目錄下,
在D:\web\jsp\Tomcat 5.0\webapps\ROOT\jekyweb\guestBook\目錄下放index2.jsp檔案
set classpath=%classpath%;D:\web\jsp\Tomcat 5.0\webapps\ROOT\jekyweb\guestBook\
就出這樣的錯了,希望各位幫幫我啊![emb10]

相關文章