title: How to create a session object?
body: <p>I am creating a login page for my web application. I want to create a session object whenever
  a new user logged in. I know the concept of sessions, but i didnt used that before. Can i do it with a simple class. Or, i have to move to servlet.
  If i shall do it with a simple class means, how to create a session object.</p>
  
  <hr>
  
  <h2>This is my scenario...</h2>
  
  <p><strong>The HTML CODE:</strong></p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;User Name: &lt;/td&gt;&lt;td&gt;&lt;input id="uName"  class="required" type="text" 
      size="5" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Password: &lt;/td&gt;&lt;td&gt;&lt;input id="pwd"  class="required" type="text" size="5"
      onclick="login()"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>The JS Code:</strong></p>
  
  <pre><code>function login(){
  var userDetails = { uName : null, pwd : null };
  dwr.util.getValues(userDetails);//Yes, i am using DWR.
  LoginAuthentication.doLogin(userDetails, loginResult);
  }
  
   function loginResult(nextPage){
  window.location.href = nextPage;
  }
  </code></pre>
  
  <p><strong>The Java Code:</strong></p>
  
  <pre><code>public class LoginAuthentication
  {
  public String doLogin(User user) throws SQLException, ClassNotFoundException{
      String userName = user.getUserName();
      boolean loginResult = verifyUser(user);//Another method that verifies user details with the DB.
      if (loginResult == true){
          /* Here I have to create session object,
            and i want to add the current username in that object. How to do it.*/
  
          return "MainPage.html";
      }
      else{
  
          return "loginRetryPage.html";
  
      }
     }
  </code></pre>
  
  <hr>
  
  <p>The concept that was given to me about session is pretty simple and clear. I have to create a session object after  a valid user input &amp; add the user name to that object, Destroy the object when logout was clicked. But i didnt worked on sessions before. I mean, i dont know the syntax to create a session variable. </p>
  
  <p><strong>How shall i create a session Object here?</strong></p>
  
  <p>Any suggestions would be more appreciative!!!</p>
  
  <p><strong>Thanks in Advance!!!</strong></p>