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.getConnection("jdbc:odbc:study");
Statement stmt=con.createStatement();
stmt.executeUpdate("insert into userinfo values('"+name+"','"+pwd+"')");
ResultSet rs=stmt.executeQuery("select * from userinfo");
out.print("<pre>");
out.println("All user in DB");
while (rs.next())
{
out.print("username");
out.print(rs.getString("name")+" passwor:");
out.print(rs.getString("pwd"));
}
out.print("</pre>");
rs.close();
stmt.close();
con.close();
}catch(Exception ex){
System.out.println(ex.getMessage());
}*/
}
public void clean(){
request=null;
out=null;
}
}
[解决办法]
JSP找不到CHECK_LOGIN这个类~~你确认一下你的类路径是否正确~~在JSP中用<%@ PAGE IMPORT%>再把你的类导一下~~还不行就把你那个CLASSES改称小写的~~然后把你那个类放在这个文件夹下的一个文件夹~~随便取个名字~比如叫MYAPCK~~JAVA里PACKAGE一下~~BEAN里"PACKAGE.CHECK_LOGIN"~~TOMCAT有时候不能及时更新类信息~~你试试吧~~
我的异常网推荐解决方案: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