title: Using RequestDispatcher to forward to the same page that send request
body: <p>I have a servlet, which is called "LoginServlet", an index.jsp, which has the login form (username &amp; password). I send the request to the LoginServlet, and used:</p>
  
  <pre><code>getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
  </code></pre>
  
  <p>To go back to the index.jsp with the username and user information (To display Welcome XXX on top right of the screen). The problem is, I cannot use ${requestScope.userName} to retrieve the username. The userName simply does not exist in the request. However, when I dispatched to another jsp page, it did receive the request with new information and I could retrieve it.</p>
  
  <p>I want to know is there a way to forward to the same page which send the request? I simply cannot get the data dispatched from servlet to the same page, i.e. for making user logged in</p>