请问我这段代码错在那里,谢谢!(50分)

  • 主题发起人 主题发起人 pepsi-cola
  • 开始时间 开始时间
P

pepsi-cola

Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一段显示数据库内容的代码,服务器为tomcat3.3,jsp的保存路径是C:/jakarta-tomcat-3.3/webapps/root/aaa
运行时总是显示
Error: 500
Location: /AAA/person_inf.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile C:/jakarta-tomcat-3.3/work/DEFAULT/ROOT/AAA/person_inf_1.java:61: ???? person.personbean?
person.personbean p_bean = null;
^
C:/jakarta-tomcat-3.3/work/DEFAULT/ROOT/AAA/person_inf_1.java:64: ???? person.personbean?
p_bean= (person.personbean)
^
C:/jakarta-tomcat-3.3/work/DEFAULT/ROOT/AAA/person_inf_1.java:69: ???? person.personbean?
p_bean = (person.personbean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "person.personbean");
^
3 ???
at org.apache.tomcat.facade.JasperLiaison.javac(Unknown Source)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(Unknown Source)
at org.apache.tomcat.facade.JspInterceptor.requestMap(Unknown Source)
at org.apache.tomcat.core.ContextManager.processRequest(Unknown Source)
at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
at org.apache.tomcat.core.ContextManager.service(Unknown Source)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
at java.lang.Thread.run(Thread.java:484)
请问是怎么回事?

这是person_inf.jsp

<html>
<head>
<meta http-equiv = "Content-Type" content="text/html;charset=gb2312">
<title>AAAAAA</title>
</head>
<body>
<p>AAAAAAA</p>

<table border="1" width="100%">
<%@ page language="Java" import="java.sql.*" %>
<jsp:useBean id="p_bean" scope="page" class="person.personbean" ></jsp:useBean>
<%
ResultSet RS = p_bean.executeQuery("select supplierID,companyname from suppliers");

while (RS.next())
{

out.print("<tr>");

out.print("<td width=/"50%/">");
out.print(RS.getString("supplierID"));
out.print("</td>");

out.print("<td width=/"50%/">");
out.print(RS.getString("companyname"));
out.print("</td>");

out.print("</tr>");

}
%>
</table>
</body>
</html>


以下是personbean.java,可以编译为personbean.class,无错误

package person;
import java.sql.*;

public class personbean
{
String sDBDriver = "sun.jdbs.odbc.JdbcOdbcDriver";
String sConnStr = "jdbs:odbc:Northwind_DB";
Connection conn = null;
ResultSet rs = null;

public personbean()
{
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("personbean():" + e.getMessage());

}
}
public ResultSet executeQuery(String sql)
{
rs = null;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch
(SQLException ex)
{
System.err.println("aq.executeQuery:" + ex.getMessage());
}
return rs;
}
}
 
好象都出在这儿:person.personbean
 
路径有问题。你的personbean.class放在哪?
因该放在:、web-inf/classes/person/personbean.class下
 
后退
顶部