关于问题:The value for the useBean class attribute test.textcounter is invalid.

kangsg219 2007-03-06 11:01:03
jsp初学者,我实在找不出错在哪。请牛人指点!!


pe Exception report

message

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

exception

org.apache.jasper.JasperException: /textcounter.jsp(9,0) The value for the useBean class attribute test.textcounter is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Generator.generate(Generator.java:3394)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
...全文
620 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
真的很小奚 2007-03-07
  • 打赏
  • 举报
回复
LZ程序文件在那无所谓的 要得就是CLASS文件。恭喜LZ问题解决
jjoohhnn13 2007-03-06
  • 打赏
  • 举报
回复
test/count目录下 textcounter.java 和textcounter.class
---------------------------------------------------------
你的JAVABEAN是放在 test/count目录下的
而你的调用JAVABEAN这样写<jsp:useBean id="textcounter" class="test.textcounter" scope="application" />当然找不到textcounter

把class="test.textcounter" 改成 class="test.count.textcounter"
真的很小奚 2007-03-06
  • 打赏
  • 举报
回复
确认你的textcounter类放在什么地方了在 写<jsp:useBean id="textcounter" class="test.count.textcounter" scope="application" />class=""里面要能找到textcounter。CLASS文件
真的很小奚 2007-03-06
  • 打赏
  • 举报
回复
class="test.textcounter"下面有textcounter类吗??你是package count;呀
<jsp:useBean id="textcounter" class="test.count.textcounter" scope="application" />
kangsg219 2007-03-06
  • 打赏
  • 举报
回复
IE中输入http://localhost:8080/test/textcounter.jsp,出现上面的问题,
我感觉代码没有问题,是不是文件的存放路径有问题?还是缺什么支持?
kangsg219 2007-03-06
  • 打赏
  • 举报
回复
test/count目录下 textcounter.java 和textcounter.class
package count;
import java.io.*;
public class textcounter
{ String currentrecord="";
BufferedReader bfr;
public String readfile (String path ,String files) throws FileNotFoundException
{ this.bfr=new BufferedReader (new FileReader(path+"\\"+files));
String returnstr="";
try{currentrecord=this.bfr.readLine();}
catch(IOException e ){e.printStackTrace();}
if(currentrecord==null)
{returnstr="0";}
else
{returnstr=currentrecord;}
return returnstr;
}
public void writefile(String path,String files,String counter) throws FileNotFoundException
{ int writestr=Integer.parseInt(counter)+1;
try{
PrintWriter pw=new PrintWriter(new FileOutputStream(path+"\\"+files));
pw.println(writestr);
pw.close(); }
catch(IOException e){throw new FileNotFoundException(e.getMessage());}
}
}
kangsg219 2007-03-06
  • 打赏
  • 举报
回复
我用的是tomcat6 .
test目录下textcounter.jsp
<%@ page contentType="text/html;charset=GBK" language="java" %>
<html>
<head>
<title>文本在线计数器示例</title>
</head>
<body>
<center>
<h3>文本在线计数器示例<h3>
<jsp:useBean id="textcounter" class="test.textcounter" scope="application" />
<%
string path=application.getRealPath(this.getServletName());
path=path.substring(0,path.lastIndexOf("\\"));
string counter=textcounter.readfile(path,"counter.txt");
textcounter.writerfile(path,"counter.txt",counter);
counter=textcounter.readfile(path,"counter.txt");
%>
<p>您是第<%=counter%>位访问者</p>
</center>
</body>
</html>
kangsg219 2007-03-06
  • 打赏
  • 举报
回复
问题解决了,是class文件的路径问题。
kangsg219 2007-03-06
  • 打赏
  • 举报
回复
给位说的对啊,可是改了后还是有错:
ption report

message

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

exception

org.apache.jasper.JasperException: /textcounter.jsp(9,0) The value for the useBean class attribute test.count.textcounter is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Generator.generate(Generator.java:3394)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

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

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧