日期:2014-05-18  浏览次数:21221 次

useBean引用问题
错误页面:check_login.jsp

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: /check_login.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\study\org\apache\jsp\check_005flogin_jsp.java:43: cannot resolve symbol
symbol : class check_login 
location: class org.apache.jsp.check_005flogin_jsp
  check_login test = null;
  ^


An error occurred at line: 2 in the jsp file: /check_login.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\study\org\apache\jsp\check_005flogin_jsp.java:45: cannot resolve symbol
symbol : class check_login 
location: class org.apache.jsp.check_005flogin_jsp
  test = (check_login) _jspx_page_context.getAttribute("test", PageContext.PAGE_SCOPE);
  ^


An error occurred at line: 2 in the jsp file: /check_login.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\study\org\apache\jsp\check_005flogin_jsp.java:47: cannot resolve symbol
symbol : class check_login 
location: class org.apache.jsp.check_005flogin_jsp
  test = new check_login();
  ^
3 errors



org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:437)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:497)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:476)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:464)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.



jsp页面文件:

<html>
<jsp:useBean id="test" class="check_login"/>
<head><title>check_login.jsp</title></head>
<body>
<%
test.init(request,out);
test.execute();
test.clean();
%>
</body>
</html>


chekc_login文件(已编译通过,直接防在CLASSES文件夹下,不知是否正确):

import java.sql.*;
import javax.servlet.*;
import javax.servlet.jsp.*;

public class check_login{
ServletRequest request;
JspWriter out;

public void check_login(){}

public void init(ServletRequest req,JspWriter ou){
request=req;
out=ou;
}

public void execute(){
String name;
String pwd;
name=request.getParameter("name");
pwd=request.getParameter("password");
/*try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.