title: How to get Bean data in JSP
body: <p>I have bean defined as <code>PersonBean</code> in session scope.</p>
  
  <p>What I want is find the <code>PersonBean.personId</code> in jsp page.</p>
  
  <p>I want it in jsp page, because I want to do some calculation based on this <code>personId</code>. Anyone have idea how to get the same.</p>
  
  <p>In JSP, I am able to print the same using jsf</p>
  
  <pre><code>&lt;h:outputText value="#{PersonBean.personId}" /&gt;
  </code></pre>
  
  <p>However I need this value assigned to some integer value in jsp as shown below.</p>
  
  <pre><code>&lt;h:outputText value="#{PersonBean.personId}" /&gt;
  &lt;%
     int i = new PersonBean().getPersonId;
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  %&gt;
  </code></pre>
  
  <p>I thought <code>int i = new PersonBean().getPersonId;</code> would work, however it is not working. Any idea how I get get this?</p>
  
  <h2>Update 1</h2>
  
  <p>I also tried</p>
  
  <pre><code>&lt;jsp:useBean id="sessionPersonalDataBean" class="com.sac.databean.PersonalInformationDataBean" scope="session"/&gt;
  &lt;%
     out.print("my id is " + sessionPersonalDataBean.getPersonId());
  %&gt;
  </code></pre>
  
  <p>Still I get output as <code>my id is 0</code> instead of <code>my id is 0</code>.</p>
  
  <p><strong>NOTE:</strong></p>
  
  <p>When I use, <code>&lt;h:outputText value=#{PersonalInformationDataBean.personId} /&gt;</code> I get proper output.</p>