1.Count类
  import java.io.Serializable;
public class Count implements Serializable
{
public int count=0; public void setCount(int count)
{
this.count=count;
} public int getCount()
{
return count;
} public void increment()
{
count++;
}
}
编译好以后,放在tomcat的root下的classes里面.
2.jsp文件
<html>
<body bgcolor="#ffffff">
<jsp:useBean id="count1" class="Count" scope="page" />
<jsp:useBean id="count2" class="Count" scope="page" /> Count1:<br>
<% count1.increment(); %>
You are visitor number <%=count1.getCount() %><p> Count2:<br>
<% count2.increment(); %>
You are visitor number <%=count2.getCount() %><p>
<body>
</html>
放在root下,然后运行这个JSP文件就出错啦.错误提示:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 3 in the jsp file: /10.jspsymbol  : class Count 
location: class org.apache.jsp._10_jsp
      Count count1 = null;
      ^

解决方案 »

  1.   

    Count count1 = null; 下在哪,或则你没引进Count类错误提示不全。
      

  2.   

    Count这个类放在root下的classes里面了啊,不是吗?
    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 3 in the jsp file: /10.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\work\Catalina\localhost\_\org\apache\jsp\_10_jsp.java:45: cannot resolve symbol
    symbol  : class Count 
    location: class org.apache.jsp._10_jsp
          Count count1 = null;
          ^
      

  3.   

    qinmi(亲密)  说错了。
    你把类加一个包看看呢!假如:
    类中:pakeage test;
    jsp中:
    <jsp:useBean id="count1" class="test.Count" scope="page" />
      

  4.   

    那到底这个CLASS文件放在哪里啊?root/WEB-INF/下根本没有src目录,
      

  5.   

    这个例子我是教课书的,CLASS文件真不知道放在哪里.