title: How to set a header in an HTTP response?
body: <p>I've a servlet <em>A</em> where I'm setting a header in the HTTP response:</p>
  
  <pre><code>public void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
  
      String userName=request.getParameter("userName");
      String newUrl = "http://somehost:port/ServletB";
  
      response.addHeader("REMOTE_USER", userName);
  
      response.sendRedirect(newUrl);
  }
  </code></pre>
  
  <p>Now in a servlet <em>B</em>, I'm trying to get the header value that was set in the servlet <em>A</em>:</p>
  
  <pre><code>public void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
  
      String userid = request.getHeader("REMOTE_USER");
  }
  </code></pre>
  
  <p><br>
  But here the value of <em>userid</em> is coming as <code>null</code>. Please let me know what I'm missing here.</p>