title: JSP and Beans: where to place class files
body: <p>I am new to jsp, and a have a question regarding jsp and beans.</p>
  
  <p>I created the following java file as a bean, compiled it and saved the java and the class file in <em>C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\jspfiles\WEB-INF\classes</em> folder:</p>
  
  <pre><code>package test;
  
  public class Hello
  {
  private String str;
  
      public void setStr (String value)
      {
          str = value;
      }
  
      public String getStr ()
      {
          return str;
      }
  }
  </code></pre>
  
  <p>My jsp file, test.jsp, with the following code is in <em>C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\jspfiles</em> folder.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;%@ page contentType="text/html;charset=windows-1252"%&gt;
  
  &lt;jsp:useBean id="test" class="test.Hello" scope="session"/&gt;
  </code></pre>
  
  <p>When I open the test.jsp file (http://localhost:8082/jspfiles/test.jsp),  I get this error:</p>
  
  <pre><code>HTTP Status 500 - /test.jsp (line: 4, column: 0) The value for the useBean class attribute test.Hello is invalid.
  
  type Exception report
  
  message /test.jsp (line: 4, column: 0) The value for the useBean class attribute test.Hello is invalid.
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  org.apache.jasper.JasperException: /test.jsp (line: 4, column: 0) The value for the useBean class attribute test.Hello is invalid.
      org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
      org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
      org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:149)
      org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1234)
      org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1182)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
      org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
      org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
      org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
      org.apache.jasper.compiler.Generator.generate(Generator.java:3490)
      org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  
  note The full stack trace of the root cause is available in the Apache Tomcat/7.0.34 logs.
  </code></pre>
  
  <p>What is wrong above?</p>