title: How to pass new header to sendRedirect
body: <p>I feel like this should be easy.  I have an app where all I am trying to do is have a form page (index.jsp) that calls a servlet (CheckInfo.java) which sets a new header (myHeader) and redirects the user to another page (redirect.jsp). All of these files are on the same server. The index.jsp is sending the request just fine and CheckInfo is processing and redirecting, but myHeader is not showing up on redirect.jsp.  I've read several posts talking about response.sendRedirect sends a 302 which doesn't pass headers and that I should use RequestDispatcher, but nothing seems to work.  Is there no way to send headers from a servlet to a jsp?
  Here is the servlet code:</p>
  
  <pre><code>response.setHeader("myHeader", "hey there");
  response.sendRedirect("redirect.jsp");
  </code></pre>
  
  <p>I have also tried this:</p>
  
  <pre><code>response.setHeader("myHeader", "hey there");
  RequestDispatcher view = request.getRequestDispatcher("redirect.jsp");
  view.forward(request, response);
  </code></pre>
  
  <p>And I have this in redirect.jsp:</p>
  
  <pre><code>System.out.println(request.getHeader("myHeader"));
  </code></pre>
  
  <p>This does not print anything.</p>
  
  <p>If the answer to my question is no... then I would settle for a way to set the header once I got back to the jsp.  My reverse proxy is looking for a specific header to determine whether or not to perform an action.  Obviously I tried response.addHeader() on redirect.jsp, but the page has already loaded at that point so that just made me feel dumb.</p>