输入 http://localhost:8080/11.jsp 后报错:HTTP Status 500 - --------------------------------------------------------------------------------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: -1 in the jsp file: nullGenerated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] D:\tomcat\jakarta-tomcat-4.1.24\work\Standalone\localhost\_\_11_jsp.java:41: cannot resolve symbol
    [javac] symbol  : class EmployeeBean 
    [javac] location: class org.apache.jsp._11_jsp
    [javac]       EmployeeBean employee = null;
    [javac]       ^
    [javac] D:\tomcat\jakarta-tomcat-4.1.24\work\Standalone\localhost\_\_11_jsp.java:43: cannot resolve symbol
    [javac] symbol  : class EmployeeBean 
    [javac] location: class org.apache.jsp._11_jsp
    [javac]         employee = (EmployeeBean) pageContext.getAttribute("employee", PageContext.PAGE_SCOPE);
    [javac]                     ^
    [javac] D:\tomcat\jakarta-tomcat-4.1.24\work\Standalone\localhost\_\_11_jsp.java:46: cannot resolve symbol
    [javac] symbol  : class EmployeeBean 
    [javac] location: class org.apache.jsp._11_jsp
    [javac]             employee = (EmployeeBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "EmployeeBean");
    [javac]                         ^
    [javac] 3 errors at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)

解决方案 »

  1.   

    到 work 目录底下查看 _11_jsp.java 文件,内容如下:
    package org.apache.jsp;import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import org.apache.jasper.runtime.*;public class _11_jsp extends HttpJspBase {
      private static java.util.Vector _jspx_includes;  public java.util.List getIncludes() {
        return _jspx_includes;
      }  public void _jspService(HttpServletRequest request, HttpServletResponse response)
            throws java.io.IOException, ServletException {    JspFactory _jspxFactory = null;
        javax.servlet.jsp.PageContext pageContext = null;
        HttpSession session = null;
        ServletContext application = null;
        ServletConfig config = null;
        JspWriter out = null;
        Object page = this;
        JspWriter _jspx_out = null;
        try {
          _jspxFactory = JspFactory.getDefaultFactory();
          response.setContentType("text/html;charset=ISO-8859-1");
          pageContext = _jspxFactory.getPageContext(this, request, response,
           null, true, 8192, true);
          application = pageContext.getServletContext();
          config = pageContext.getServletConfig();
          session = pageContext.getSession();
          out = pageContext.getOut();
          _jspx_out = out;      EmployeeBean employee = null;
          synchronized (pageContext) {
            employee = (EmployeeBean) pageContext.getAttribute("employee", PageContext.PAGE_SCOPE);
            if (employee == null){
              try {
                employee = (EmployeeBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "EmployeeBean");
              } catch (ClassNotFoundException exc) {
                throw new InstantiationException(exc.getMessage());
              } catch (Exception exc) {
                throw new ServletException("Cannot create bean of class " + "EmployeeBean", exc);
              }
              pageContext.setAttribute("employee", employee, PageContext.PAGE_SCOPE);
            }
          }
          out.write("\r\n");
    employee.setName("tx");
          out.write("\r\n\r\n");
          out.write("<html>\r\n");
          out.write("<head>\r\n");
          out.write("<title>title");
          out.write("</title>\r\n");
          out.write("</head>\r\n");
          out.write("<body>\r\n");
          out.write("<table border=\"0\">\r\n");
          out.write("<tr>\r\n");
          out.write("<td>name:");
          out.write("</td>");
          out.write("<td>");
          out.write("<b>");
    employee.getName();
          out.write("</b>");
          out.write("</td>\r\n");
          out.write("</tr>\r\n\r\n");
          out.write("</table>\r\n");
          out.write("</body>\r\n");
          out.write("</html>");
        } catch (Throwable t) {
          out = _jspx_out;
          if (out != null && out.getBufferSize() != 0)
            out.clearBuffer();
          if (pageContext != null) pageContext.handlePageException(t);
        } finally {
          if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
        }
      }
    }请问这究竟是哪儿错了?
      

  2.   

    <%=employee.getName();%>
    加个=号
      

  3.   

    <jsp:useBean id="employee" class="EmployeeBean" scope="page"/>///加了scope
    <%employee.setName("tx");%><html>
    <head>
    <title>title</title>
    </head>
    <body>
    <table border="0">
    <tr>
    <td>name:</td><td><b><%=employee.getName()%></b></td>///去分号,加了等号
    </tr></table>
    </body>
    </html>
      

  4.   

    <jsp:useBean id="employee" class="EmployeeBean" scope="page"/>中的scope属性必须有;
    <%=employee.getName()%>中的等号不是报错的原因,也可以写成<%out.print(employee.getName();%>
      

  5.   

    我的测试是如果仅仅是上面的程序片段的话,不会出现错误。楼主是不是省略了部分程序????另楼上的 scope属性不是必须有的,程序默认的生命周期为 page
    看上面程序中的下面部分就可以得知的:
          synchronized (pageContext) {
            employee = (EmployeeBean) pageContext.getAttribute("employee", PageContext.PAGE_SCOPE);
                ^^^^^^^^^^
      

  6.   

    是不是 employee类的位置放的有问题,该jsp找不到,再检查一下
      

  7.   

    以上各位说的方法我都试过了,均不成功,
    还有一点我要澄清一下:所有的程序代码都帖出来了,绝对没有任何省略。麻烦大家再帮忙仔细看看下面的出错提示,“^”所指的地方是否就是出错的关键所在?
    An error occurred at line: -1 in the jsp file: nullGenerated servlet error:
        [javac] Since fork is true, ignoring compiler setting.
        [javac] Compiling 1 source file
        [javac] Since fork is true, ignoring compiler setting.
        [javac] D:\tomcat\jakarta-tomcat-4.1.24\work\Standalone\localhost\_\_11_jsp.java:41: cannot resolve symbol
        [javac] symbol  : class EmployeeBean 
        [javac] location: class org.apache.jsp._11_jsp
        [javac]       EmployeeBean employee = null;
        [javac]       ^
        [javac] D:\tomcat\jakarta-tomcat-4.1.24\work\Standalone\localhost\_\_11_jsp.java:43: cannot resolve symbol
        [javac] symbol  : class EmployeeBean 
        [javac] location: class org.apache.jsp._11_jsp
        [javac]         employee = (EmployeeBean) pageContext.getAttribute("employee", PageContext.PAGE_SCOPE);
        [javac]                     ^
        [javac] D:\tomcat\jakarta-tomcat-4.1.24\work\Standalone\localhost\_\_11_jsp.java:46: cannot resolve symbol
        [javac] symbol  : class EmployeeBean 
        [javac] location: class org.apache.jsp._11_jsp
        [javac]             employee = (EmployeeBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "EmployeeBean");
        [javac]                         ^
        [javac] 3 errors
      

  8.   

    我猜会不会是你的EmployeeBean不在classpath里?
      

  9.   

    既然这样,那我也认为是你的EmployeeBean并不在你的classpath里边。
      

  10.   

    tomcat设置有问题吧!你事实tomcat实验页能否出来。
      

  11.   

    实验页一直都是好的,就是这个servlet出不来。EmployeeBean.class所在目录: D:\tomcat\jakarta-tomcat-4.1.24\webapps\ROOT 环境变量: classpath=D:\tomcat\jakarta-tomcat-4.1.24\webapps\ROOT;…………(省略)应该不是环境变量的问题了吧。
      

  12.   

    你编译好的类放在哪儿?
    是不是webapps/ROOT/WEB-INF/classes/EmployeeBean.class