title: Session Object is returning Null
body: <pre><code>public class FirstServletClass extends HttpServlet{
  
      /**
       * 
       */
      private static final long serialVersionUID = -45872253821246793L;
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException ,IOException {
          response.setContentType("text/html");
          PrintWriter pw = response.getWriter();
          HttpSession session = request.getSession();
          if(request.getParameter("userName")!=null){
              session.setAttribute("UserName", request.getParameter("userName")) ;
          }
          pw.print("HI From Server &lt;br/&gt;");
          pw.print("Accessing Value from Response object    "+request.getParameter("userName")+"&lt;br/&gt;");
          pw.print("Accessing Value from Session object    "+(String)session.getAttribute("userName")+"&lt;br/&gt;");
  
          System.out.println("Get Method Called");
      }
  
  
  }
  </code></pre>
  
  <p>When hitting url "<a href="http://localhost:8080/Servlets/niteshServlet?userName=nitesh" rel="nofollow">http://localhost:8080/Servlets/niteshServlet?userName=nitesh</a>" below output is coming:</p>
  
  <blockquote>
    <p>HI From Server</p>
    
    <p>Accessing Value from Response object nitesh</p>
    
    <p>Accessing Value from Session object null</p>
  </blockquote>
  
  <p>Please suggest, Where am I wrong?</p>