title: Java servlet: request.getParameter and request.setAttribute connected in a way I don't understand
body: <p>At the top of my doPost method I grab a few parameters that I previously set in the JSP using a basic form: </p>
  
  <pre><code>protected void doPost(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
  
          String serverName = request.getParameter("serverName");
          String destFileName = request.getParameter("destFileName");         
          String userName = request.getParameter("userName");
          String Message= request.getParameter("Message");
  </code></pre>
  
  <p>and at the end of the doPost method I add them back to the request object using setAttribute:           </p>
  
  <pre><code>        request.setAttribute("userName ", userName );           
          request.setAttribute("destFileName", destFileName);
          request.setAttribute("serverName", serverName); 
          request.setAttribute("Message", Message);   
  
          request.getRequestDispatcher(page).forward(request, response);
  </code></pre>
  
  <p>And then I get them in my JSP via request.getParameter again: </p>
  
  <pre><code>&lt;%  /** if the parameters are already in place, grab them **/
      String destFileName = request.getParameter("destFileName");
      String user = request.getParameter("user");
      String serverName = request.getParameter("serverName");
      String Message = request.getParameter("Message");           
  %&gt;
  </code></pre>
  
  <p>And this works, unless I've <em>rewritten</em> the value on its way through the doPost method. If that is the case, then I have to use request.getAttribute in the JSP to retrieve it since request.getParameter will retrieve the value as it was defined at the top of the doPost method, ignoring any changes that were made between the top and the bottom. </p>
  
  <p>Does anyone have an explanation of this? I've got everything working, but I'd like to understand why I spent a couple of hours of frustration figuring out what was wrong.</p>