Reputation: 15489
I hava a servlet which handles some resources files, and I need to add a response header before I forward the request to the real jsp file.
response.setHeader("a", "b");
request.getRequestDispatcher("1.jsp").forward(request, response);
I need to send that header directly to the browser, But it did not work, I tried to use firebug to watch the http request and its response, how can I do that?
Upvotes: 1
Views: 10509
Reputation: 1155
The headers are being cleaned up. Just curious, what stops you from using request.setAttribute()
?
Upvotes: 0
Reputation: 35961
Try to use .include(request, response)
instead. Probably it's a .forward()
feature to fully clean response object before forwarding.
See http://download.oracle.com/javaee/5/api/javax/servlet/RequestDispatcher.html
Upvotes: 1
Reputation: 309
If you want to use some data added by the servlet in the 1.jsp code, I suggest you use request.setAttribute method. response.addHeader/setHeader put some data into the response'header. Generally the data in the response header is used by the browser.
Upvotes: 0
Reputation: 39887
How do you know that it is not working? Please read this JR thread, I believe you are expecting similar thing.
Upvotes: 0