title: session().getAttribute is returning null
body: <p>I have a servlet which calls a jsp page.
  In the servlet I am retrieving the username provided at the login correctly.
  But after setting the same in session, when i access the called jsp page, its returning null.</p>
  
  <h2>Servlet Code:</h2>
  
  <pre><code>public class AdminServlet extends HttpServlet {
  /**
   * 
   */
  private static final long serialVersionUID = -4244742541587179390L;
  
  public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      String userName =  request.getParameter("name");
      System.out.println("UserName: " + userName); // Here it prints the username properly
      request.getSession(true).setAttribute(request.getParameter("name"), userName );
      RequestDispatcher rd = request.getRequestDispatcher("upload.jsp");
      rd.forward(request, response);
  //  response.sendRedirect("upload.jsp");
  }
  
  public void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      doGet(request,response);
  }
  }
  </code></pre>
  
  <p>JSP Code snippet where I am accessing this:</p>
  
  <pre><code>&lt;label class="message"&gt;Welcome &lt;%= session.getAttribute("userName") %&gt;&lt;/label&gt;
  </code></pre>
  
  <p>What am I doing wrong here? Can anyone help please</p>