急急!jsp加载bean是出现的错误,请各位帮我看看

onguca 2004-04-08 05:01:20
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: 51 in the jsp file: /jspdev/manage.jsp

Generated servlet error:
[javac] Compiling 1 source file

D:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\jspdev\manage_jsp.java:94: cannot resolve symbol
symbol : class Product
location: class org.apache.jsp.jspdev.manage_jsp
Product product = null;
^



An error occurred at line: 51 in the jsp file: /jspdev/manage.jsp

Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\jspdev\manage_jsp.java:96: cannot resolve symbol
symbol : class Product
location: class org.apache.jsp.jspdev.manage_jsp
product = (Product) _jspx_page_context.getAttribute("product", PageContext.PAGE_SCOPE);
^



An error occurred at line: 51 in the jsp file: /jspdev/manage.jsp

Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\jspdev\manage_jsp.java:98: cannot resolve symbol
symbol : class Product
location: class org.apache.jsp.jspdev.manage_jsp
product = new Product();
^
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)


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

...全文
9 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
amortal 2004-04-09
Product是你自己的类吧,应该也要做类似的import啊
<%@ page import="com.DatabaseConn"%>
还有,条件应该是
if(rs.next()){
!不要
回复
wypang0903 2004-04-09
你能确保bean文件的位置吗?
web-inf/classes/com/DatabaseConn
回复
onguca 2004-04-08
Product类和product.jsp太长了,所以我没贴上来,我贴上来的这段代码也出现了类的实例加载不上去的问题,至于你提出错误的那段我改成:
if(!rs.next()){
session.setAttribute("userid",username);
session.setAttribute("name",rs.getString("name"));
session.setAttribute("phone",rs.getString("phone"));
session.setAttribute("street",rs.getString("street"));
session.setAttribute("state",rs.getString("state"));
session.setAttribute("city",rs.getString("city"));
session.setAttribute("zipCode",rs.getString("zipCode"));
session.setAttribute("email",rs.getString("email"));
session.setAttribute("cardNumber",rs.getString("cardNumber"));
session.setAttribute("cardType",rs.getInt("cardType"));
session.setAttribute("userType",rs.Int("userType"));
int count=result.getInt("userLogCount");
session.setAttribute("userLogCount",new Integer(count));
--------------------------------------------
对吗?但是那个实例加载问题还是没解决呀
回复
wypang0903 2004-04-08
if(rs!=null){
session.setAttribute("userid",username);
session.setAttribute("name",rs.getString("name"));
session.setAttribute("phone",rs.getString("phone"));
session.setAttribute("street",rs.getString("street"));
session.setAttribute("state",rs.getString("state"));
session.setAttribute("city",rs.getString("city"));
session.setAttribute("zipCode",rs.getString("zipCode"));
session.setAttribute("email",rs.getString("email"));
session.setAttribute("cardNumber",rs.getString("cardNumber"));
session.setAttribute("cardType",rs.getInt("cardType"));
session.setAttribute("userType",rs.Int("userType"));
int count=result.getInt("userLogCount");
session.setAttribute("userLogCount",new Integer(count));
===========================
你这样能出来数据么,指针在第一行之前那
回复
wypang0903 2004-04-08
你这些文件中没有用到Product product呀,怎么会报他的错呢?
回复
onguca 2004-04-08
JSP login.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.sql.*"%>
<%@ page import="com.DatabaseConn"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<jsp:useBean id="login" scope="page" class="com.Login">
<jsp:setProperty name="login" property="UserName" param="username"/>
<jsp:setProperty name="login" property="Password" param="password"/>
</jsp:useBean>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("passwrod");
Connection mycon=null;
Statement stmt=null;
ResultSet rs=null;
DatabaseConn con;
mycon=con.getConnection();
rs=login.Loginning();
if(rs!=null){
session.setAttribute("userid",username);
session.setAttribute("name",rs.getString("name"));
session.setAttribute("phone",rs.getString("phone"));
session.setAttribute("street",rs.getString("street"));
session.setAttribute("state",rs.getString("state"));
session.setAttribute("city",rs.getString("city"));
session.setAttribute("zipCode",rs.getString("zipCode"));
session.setAttribute("email",rs.getString("email"));
session.setAttribute("cardNumber",rs.getString("cardNumber"));
session.setAttribute("cardType",rs.getInt("cardType"));
session.setAttribute("userType",rs.Int("userType"));
int count=result.getInt("userLogCount");
session.setAttribute("userLogCount",new Integer(count));
count++;
session.setAttribute("userLastLogTime",result.getString("userLastLogTime"));
java.util.Date time1=new java.util.Date();//获得系统当前时间
String sqltime=new Timestamp(time1.getTime()).toString();//将当前时间转换成sql server可以识别的对象
//更新登录信息。
stmt=mycon.CreateStatement();
stmt.execute("update user_info set userLogCount="+count+",userLastLogTime='"+sqltime+"' where userId='" + id +"'");
//关闭数据库连接相关的资源。
response.sendRedirect("index.jsp");
}
else {
response.sendRedirect("index.jsp");
}
%>
</body>
</html>

BEAN login.java

/*
* 创建日期 2004-3-27
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com;
import java.sql.*;
import com.DatabaseConn;
/**
* @author Sant
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class Login {
static Connection mycon;
DatabaseConn con;
Statement stmt;
private String UserName;
private String Password;
//DatabaseConn con;
public ResultSet Loginning(){
String sql;
int count;
ResultSet rs = null;
try{
mycon = con.getConnection();
stmt = mycon.createStatement();
sql = "select * from user_info where userid='"+ UserName +"'and password='"+ Password +"'";
rs = stmt.executeQuery(sql);
if (!rs.next()){
rs = null;
mycon.close();
stmt.close();
}
}catch(SQLException se){
System.err.println("jspdev.Login.Loginning(): "+se.getMessage());
}
return rs;
}
/**
* @return
*/
public String getPassword() {
return this.Password;
}

/**
* @return
*/
public String getUserName() {
return this.UserName;
}

/**
* @param string
*/
public void setPassword(String password) {
this.Password = password;
}

/**
* @param string
*/
public void setUserName(String username) {
this.UserName = username;
}

}
回复
wypang0903 2004-04-08
肯定是导入有问题,否则他的实例是不会建立失败的
回复
wypang0903 2004-04-08
你最好能把你的代码贴上来,有很多东西不看源码是找不到答案的
回复
onguca 2004-04-08
导入了呀,包的路径也都是对的,就是找不到哪里错了
回复
wypang0903 2004-04-08
估计是你的BEAN没有导入的问题
回复
hup 2004-04-08
up
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-04-08 05:01
社区公告
暂无公告