菜鸟求助!请各位大侠帮帮忙啊

liqun5218 2004-09-14 10:11:55
初学Jsp,照书上的用javaBeans实现一个计数器,可运行jsp文件时提示如下错误:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.


exception org.apache.jasper.JasperException: /count/JavaBeansCounter.jsp(9,0) The value for the useBean class attribute counter.counter is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1225)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3269)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
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.27 logs.



请各位大侠帮我看看是什么错误,在那里出错了,先谢谢了
...全文
33 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
liqun5218 2004-09-14
JavaBeansCounter.jsp文件为:

<%@page contentType="text/html;charset=gb2312"%>


<html>
<head>
<title>用JavaBeans模块化的文字模式访问计数器</title>
</head>
<body bgcolor="CCCCFF">
<jsp:useBean id="counter" scope="request" class="counter.counter"/>
<%
counter.path="count.txt";
String count=counter.doCount();
%>
<p align="center"></p>
<h1>用JavaBeans模块化的文字模式访问计数器</h1>
<h3 align="center">你是本网页的第
<font color="ff0000" size="7"><%=count%></font>
名访客!</h3>
</body>
</html>
回复
liqun5218 2004-09-14
JavaBeans文件为:

package counter;
import java.io.*;
public class counter extends Object
{
public String path="";
public String doCount() throws FileNotFoundException
{
BufferedReader file;
String countFile=path;
file=new BufferedReader(new FileReader(countFile));
String readStr="";
int writeStr=1;
try
{
readStr=file.readLine();
}
catch(IOException e)
{
System.out.println("读取数据失败");
}
if(readStr=="")
readStr="没有任何记录";
else
writeStr=Integer.parseInt(readStr)+1;
try
{
PrintWriter pw=new PrintWriter(new FileOutputStream(countFile));
pw.println(writeStr);
pw.close();
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
return readStr;
}
}

回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-14 10:11
社区公告
暂无公告