JSP页面中使用bean的问题
saoyu 2004-05-08 01:06:16 我在test.jsp中使用数据库连接的bean,为什么test.jsp编译不过去呢?
test.jsp:
<%@ page import="java.sql.*"%>
<jsp:useBean id="DBbean" scope="page" class="DBbean"/>
<%
ResultSet rs = DBbean.Query("select * from test");
rs.next();
out.print(rs.getString("name"));
rs.close();
%>
页面错误输出:
type Exception report
message
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: /test.jsp
Generated servlet error:
[javac] Compiling 1 source file
E:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\miniticket\org\apache\jsp\test_jsp.java:45: cannot resolve symbol
symbol : class DBbean
location: class org.apache.jsp.test_jsp
DBbean DBbean = null;
^
An error occurred at line: 2 in the jsp file: /test.jsp
Generated servlet error:
E:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\miniticket\org\apache\jsp\test_jsp.java:47: cannot resolve symbol
symbol : class DBbean
location: class org.apache.jsp.test_jsp
DBbean = (DBbean) _jspx_page_context.getAttribute("DBbean", PageContext.PAGE_SCOPE);
^
An error occurred at line: 2 in the jsp file: /test.jsp
Generated servlet error:
E:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\miniticket\org\apache\jsp\test_jsp.java:49: cannot resolve symbol
symbol : class DBbean
location: class org.apache.jsp.test_jsp
DBbean = new DBbean();
^
3 errors
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)