title: Accessing bean from Jsp
body: <p>I searched on this forum but haven't got appropriate solution. And if by mistake this one is duplicate then sorry.</p>
  
  <p>Coming to problem...
  I'm setting the values from one of my HTML using servlet like this
  code for index.html</p>
  
  <pre><code>&lt;FORM METHOD="POST" ACTION="user"&gt;
  What's your name? &lt;INPUT TYPE="TEXT" NAME="username" SIZE=20&gt;`
  </code></pre>
  
  <p>code for servlet</p>
  
  <pre><code>package test;
    ......
  UserBean ub = new UserBean();
  String name = request.getParameter("username");
  ub.setFirstName(name);
  request.setAttribute("user",ub);
  RequestDispatcher rd=request.getRequestDispatcher("/getJsp.jsp");
  rd.forward(request,response);
  </code></pre>
  
  <p>both servlet and bean are placed in package called test.</p>
  
  <p>code for UserBean:</p>
  
  <pre><code>private String firstName;
  
  public String getFirstName() {
      return firstName;
  }
  
  public void setFirstName(String firstName) {
      this.firstName = firstName;
      System.out.println(firstName);
  }
  </code></pre>
  
  <p>From the bean I'm able to print the proper value for name on server console.
  After setting the values from servlet i'm trying to acceess bean values from the JSP called getJsp.jsp</p>
  
  <p>getJsp.jsp</p>
  
  <pre><code>&lt;table&gt;
     &lt;jsp:useBean id="user" type="test.UserBean" class="test.UserBean" scope="request" &gt;   
      &lt;tr&gt;
         &lt;td&gt;  Id : &lt;/td&gt;
         &lt;td&gt; &lt;jsp:getProperty name="user" property="firstName"/&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;/jsp:useBean&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>When accessing the bean properties from JSP i'm getting the following error:</p>
  
  <blockquote>
    <p>org.apache.jasper.JasperException: /getJsp.jsp (line: 10, column: 1) The value for the useBean class attribute UserBean is invalid.</p>
  </blockquote>
  
  <p>I'm not able to understand the problem in the code for this error. 
  Help me out please.</p>
  
  <p>Thank you.</p>