在你的bean程序前加入包,
package ****;
然后在classes中建一个****的文件夹,将编译后的bean的class文件复制到其中。
引用时用:
<jsp:useBean id="myBean" class="****.BeanTest" scope="session"/>

解决方案 »

  1.   

    我试了,也还有错
    Generated servlet error:
        [javac] Since fork is true, ignoring compiler setting.
        [javac] Compiling 1 source file
        [javac] Since fork is true, ignoring compiler setting.
        [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\dirtree\beantest_jsp.java:42: package aa does not exist
        [javac]       aa.BeanTest bt = null;
        [javac]         ^
        [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\dirtree\beantest_jsp.java:44: package aa does not exist
        [javac]         bt = (aa.BeanTest) pageContext.getAttribute("bt", PageContext.PAGE_SCOPE);
        [javac]                 ^
        [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\dirtree\beantest_jsp.java:47: package aa does not exist
        [javac]             bt = (aa.BeanTest) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "aa.BeanTest");
        [javac]                     ^
        [javac] 3 errors调用页面
    <%@ page contentType="text/html; charset=gb2312" language="java" %>
    <jsp:useBean id="bt" scope="page" class="aa.BeanTest"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    </head>
    <body>
      <%
    out.print(bt.getStr());
      %>
    </body>
    </html>bean程序
    package aa;public class BeanTest {
    String s=null;

    public String getStr(){
    s="Hello World";
    return s;
    }}
      

  2.   

    BeanTest.class是否在aa文件夹下面!
      

  3.   

    把BeanTest.class放到aa/web-inf/classes/****下面