title: How do I set JSP UseBean values from a servlet
body: <p>I am writing a web application that uses a JSP usebean tag in the session scope as shown below</p>
  
  <pre><code>&lt;jsp:useBean id="userSession" class="project.session.UserSession" scope="session" /&gt;
  </code></pre>
  
  <p>I have also written a filter which does some processing and needs to set some values on the userSession bean. How do I get a handle onto the object and set values on it? I have tried getting the object from session as shown below, but this method doesn't work.</p>
  
  <pre><code>UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
  </code></pre>
  
  <p>I use Tomcat for development. </p>