[求助]jsp+javaBean除錯環境問題!
請問在瀏覽器(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]
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]
相關文章
- ngrok+express解決本地環境中微信介面除錯問題Express除錯
- 求助:jbuilder8環境下在servlet中使用EJB的問題UIServlet
- hyperf配置yasd除錯環境除錯
- FLEX - 開發環境:除錯Flex開發環境除錯
- MAC環境下PHP開發除錯環境搭建MacPHP除錯
- ZanProxy —— 原生程式碼除錯線上頁面,環境再也不是問題除錯
- vs搭建遠端除錯環境除錯
- PHP開發除錯環境建立PHP除錯
- windbg 搭建雙擊除錯環境除錯
- risc-v環境搭建及除錯除錯
- Vue生產環境除錯的方法Vue除錯
- step 1 :搭建開發除錯環境除錯
- Flutter開發環境搭建和除錯Flutter開發環境除錯
- [實用] 如何配置 iview 除錯環境View除錯
- 除錯cmp問題除錯
- RocketMQ系列-搭建Namesrv原始碼除錯環境MQ原始碼除錯
- 微信開發的本地除錯環境搭建除錯
- 彙編環境下的原始碼除錯原始碼除錯
- 打造最舒適的 webview 除錯環境WebView除錯
- go除錯的問題。Go除錯
- JDBC問題,求助JDBC
- 解決所有環境問題
- golang 開發環境問題Golang開發環境
- Golang GRPC 環境 問題GolangRPC
- Linux下搭建FFmpeg開發除錯環境Linux除錯
- uni-app 模擬機除錯環境搭建APP除錯
- webpack(1)安裝環境與解決環境問題Web
- 關於 swoole 除錯問題除錯
- this問題 以及 webstorm 除錯介面WebORM除錯
- 求助,castor的問題AST
- 求助!castor unmarshall問題AST
- VS - 打斷點/本地除錯/遠端除錯 問題斷點除錯
- 解決NLTK包下載出錯問題及NLP環境測試
- mac 配置mysql環境 Navicat 問題MacMySql
- Flutter配置環境常見問題Flutter
- go專案起步-環境問題Go
- Linux 0.11 實驗環境搭建與除錯Linux除錯
- Linux 環境安裝 Xdebug 進行除錯Linux除錯