title: How to set session attribute in java?
body: <p>I am able to set session attribute in scriptlet  but when I am trying to set session attribute inside java class it shows error like "session cannot be resolved".
  So how to set session in java?</p>
  
  <pre><code>&lt;%String username = (String)request.getAttribute("un");
  session.setAttribute("UserName", username);%&gt;
  </code></pre>