这个问题是怎么回事???(50分)

  • 主题发起人 主题发起人 NATASHA
  • 开始时间 开始时间
N

NATASHA

Unregistered / Unconfirmed
GUEST, unregistred user!
我在JSP里use JavaBean出现了如下问题,哪位大哥帮忙看看:
============================
A Servlet Exception Has Occurred
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 8 in the jsp file: /Bank_app/Interest_calc.jsp
Generated servlet error:
J:/J2EE131/repository/sammy/web/Bank_app/_0002fBank_0005fapp_0002fInterest_0005fcalc_jsp.java:71: Class org.apache.jsp.Int_Calc not found.
Int_Calc IntCalc = null;
^

An error occurred at line: 8 in the jsp file: /Bank_app/Interest_calc.jsp
Generated servlet error:
J:/J2EE131/repository/sammy/web/Bank_app/_0002fBank_0005fapp_0002fInterest_0005fcalc_jsp.java:74: Class org.apache.jsp.Int_Calc not found.
IntCalc= (Int_Calc)
^

 
IntCalc是在哪里的定义的???
可以贴出相关代码看看么???
 
//JAVA_HOME: J:/JDK131
//J2EE_HOME: J:/J2EE131
//TOMCAT_HOME: C:/JBuilder6/jakarta-tomcat-3.2.3
//Classpath = .;J:/JDK131/lib/tools.jar;J:/J2EE131/lib/j2ee.jar;J:/_JavaT;J:/J2EE131/lib/classes
//J:/JavaT/banks/Int_Calc.java
import java.io.*;
import java.sql.*;
import java.util.*;
public class Int_Calc {
private String amount;
privatedo
uble int_amount;
private String period;
privatedo
uble int_period;
privatedo
uble rateInt;
private String rate1;
privatedo
uble interest;
public Int_Calc() {
}
public String getAmount() { return amount;
}
public void setAmount(String value) {
amount = value;
int_amount =do
uble.parseDouble(amount);
}
public void setPeriod(String value) {
period = value;
int_period =do
uble.parseDouble(period);
}
public String getPeriod() { return period;
}
public void setRate1(String value) {
rate1 = value;
rateInt =do
uble.parseDouble(rate1);
System.out.println(rateInt);
}
public String getRate1() { return rate1;
}
publicdo
uble getInterest() {
interest = (int_period * int_amount * rateInt) / 100;
return interest;
}
}
//Interest_calc.jsp
<html>
<head>
<title>Money Banks, Inc. -- Interest Calculator</title>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
</head>
<%@ page language="java" %>
<%@ page errorPage="error.jsp" %>
<jsp:useBean id="IntCalc" class="Int_Calc" scope="page"/>
<body bgcolor="#ccccFF" bgproperties="fixed">
<p>&amp;nbsp;</p>
<table width="100%" border="0" height="42">
<tr>
<td height="36" width="50%"><b><i><font size="5">Money Banks, Inc.</font></i></b></td>
<td height="36" width="50%">&amp;nbsp;</td>
</tr>
</table>
<p align="center"><b><font size="4">Interest Calculator</font></b></p>
<table width="100%" border="0">
<tr>
<td width="36%"><b><font size="4">Enter Principal Amount:</font></b></td>
<td width="64%">
<%= (String)request.getParameter("amount") %>
<%! int amt;
%>
<% String str1 = request.getParameter("amount");
str1 = str1.trim();
%>
<jsp:setProperty name="IntCalc" property="amount" value="<%=str1%>"/>
</td>
</tr>
<tr>
<td width="36%"><b><font size="4">Enter Period in Months:</font></b></td>
<td width="64%">
<%= (String)request.getParameter("period") %>
<% String prd = request.getParameter("period");
prd = prd.trim();
%>
<jsp:setProperty name="IntCalc" property="period" value="<%=prd%>"/>
</td>
</tr>
<tr>
<td width="36%"><b><font size="4">Enter Rate of Interest:</font></b></td>
<td width="64%">
<%= (String)request.getParameter("int_rate") %>
<% String str2 = request.getParameter("int_rate");
str2 = str2.trim();
%>
<jsp:setProperty name="IntCalc" property="rate1" value="<%=str2%>"/>
</td>
</tr>
<tr>
<td width="36%"><font size="4"><b>Interest</b>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<b>Payable:</b></font></td>
<td width="64%">
<%do
uble tot_int = IntCalc.getInterest();
out.println(tot_int);
%>
</td>
</tr>
</table>
<p align="center"><input type="button" value="OK" name="OK" onClick="show_Home()"></p>
<script language="JavaScript">
function show_Home() {
open("Home_page.htm");
}
</script>
</body>
</html>
 
Int_Calc.java
的开头需要加上
package yurpackage;
然后在Interest_calc.jsp
里改成<jsp:useBean id="IntCalc" class="yurpackage.Int_Calc" scope="page"/>
造成IntCalc找不到是因为你的类的路径无法被程序找到,
所以它给你指定了个默认的org.apache.jsp.Int_Calc ,
那样是肯定就找不到了。
 
需要运行和设置tomcat么?
 
假如你的package名字叫yourpackage
jsp在:
D:/jb/app/defaultroot/Interest_calc.jsp.
那么Int_Calc.class文件应该放在
D:/jb/app/defaultroot/WEB-INF/classes/yourpackage/Int_Calc.class.
其它不用设置的。
以上是假定你的jsp发布目录为:D:/jb/app/defaultroot/
 
>jsp在:
>D:/jb/app/defaultroot/Interest_calc.jsp.
>那么Int_Calc.class文件应该放在
>D:/jb/app/defaultroot/WEB-INF/classes/yourpackage/Int_Calc.class
是不是要用jar来生成文件???
 
能不能给我详细讲讲JSP中怎么用JavaBeans。
我再加100~200分。
 
我晕:(
我在CSDN上写那个counter怎么到你那里去了???
这个Bank_app.rar无法打开:(
重新发一次吧。
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
974
import
I
I
回复
0
查看
2K
import
I
I
回复
0
查看
3K
import
I
后退
顶部