There\'s a thrird party app that needs to get information via custom http headers, so I wrote a simple test app that creates this headers and then redirects to a page that l
With a redirect you're basically instructing the client (the webbrowser) to fire a brand new HTTP request. A brand new request also means a brand new response. Replace it by a forward:
request.getRequestDispatcher("header.jsp").forward(request, response);
Or if you actually want to have it on the redirected request, then create a Filter
which is mapped on /header.jsp
and modifies the header accordingly.
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
((HttpServletResponse) response).setHeader("foo", "bar");
chain.doFilter(request, response);
}
Also note that you're displaying the request headers in the header.jsp
instead of response headers. Since there's no direct API avaliable to display the response headers, you'd like to investigate them using an external HTTP header sniffing tool like Firebug (the Net panel) or Fiddler.