这个提示包不存在的错误是怎么回事
小弟用javabean连数据库,从数据库中提取数据并显示在jsp 页面,数据源已建立,连接已经成功,但jsp页面提示如下错误
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 2 in the jsp file: /sfjs.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:\TOMCAT\Tomcat 4.1\work\Standalone\localhost\gongshui\sfjs_jsp.java:46: package test does not exist
test.test test_bean = null;
^
An error occurred at line: 2 in the jsp file: /sfjs.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 4.1\work\Standalone\localhost\gongshui\sfjs_jsp.java:48: package test does not exist
test_bean = (test.test) pageContext.getAttribute( "test_bean ", PageContext.PAGE_SCOPE);
^
An error occurred at line: 2 in the jsp file: /sfjs.jsp
Generated servlet error:
D:\TOMCAT\Tomcat 4.1\work\Standalone\localhost\gongshui\sfjs_jsp.java:51: package test does not exist
test_bean = (test.test) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "test.test ");
^
3 errors
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:248)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
我写的包已经编译并放在\WEB-INF\CLASSES文件夹下,代码:
package test;
import java.sql.*;
public class test
{
String sDBDriver= "sun.jdbc.odbc.JdbcOdbcDriver ";
Connection conn=null;
ResultSet rs=null;
Statement stmt=null;
int count;
public void Connect(){
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println( "personbean(): "+e.getMessage());
}
try{
conn=DriverManager.getConnection( "jdbc:odbc:szgs ", "szgs ", "szgs ");
}
catch(Exception ex){
System.err.println( "executeQuery: "+ex.getMessage());
}
}
public ResultSet executeQuery(String sql){ //查询函数
try{
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(Exception ex){
System.err.println( "executeQuery: "+ex.getMessage());
}
return rs;
}
/*public ResultSet executeQuery(String sql) throws SQLException
{
stmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
return rs;
}*/
public int executeUpdate(String sql){ //update函数
try{
stmt=conn.createStatement();
count=stmt.executeUpdate(sql);
}
catch(Exception ex){
System.err.println( "executeUpsert: "+ex.getMessage());
}
return count;
}
public void Close(){
try{
rs.close();
stmt.close();
conn.close();
}
catch(Exception ex){
System.err.println( "close: "+ex.getMessage());
}
}
public boolean closeConn()
{
try
{
if (rs!=null) rs.close();
if (stmt!=null) stmt.close();
if (conn!=null) conn.close();
return true;
}
catch ( SQLException ex )
{
System.err.println( "数据库关闭错误: " + ex.getMessage());
return false;
}
}
}
各位高人指点迷啊
[解决办法]
我写的包已经编译并放在\WEB-INF\CLASSES文件夹下
-------
注意:
1.classes要小写
2.test.class要放到test目录下, 如:\WEB-INF\classes\test\test.class
3.更改class文件,要重启tomcat
[解决办法]
调用JAVABEAN你为什么不用 <jsp:useBean= "id " scope= " " class= "bao.lei "/>
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html