You are trying to treat a header like attributes. If you need to set and display something, use an attribute.
But now an explanation why this is "not working".
A request is something you send from your browser. The response is what it expects to get back. The headers in the request are determined by your browser when it sends the request to the server. Those headers cannot change. Actually, not much on the request object can change. Why? The browser is sending a big, long, nasty chunk of text to the server. The request (HttpServletRequest) object in
J2EE is merely an abstraction of that nasty text. It deals with the ugliness of parsing out that text and provides a clean
Java class interface instead to make your life easier.
The headers on the response are only to be set to communicate something to the browser. For instance, a header can be used to tell the browser not to cache the response. Similarly, the response object is an abstraction to the big, long, nasty chunk of text that the server is going to return to the browser. Most of the things you alter on the response object are meant for the browser, not for the developer.