i have successfully set the httpServletResponse().setHeader("custtype", "permanent") but when i try to retrieve it httpServletResponse().getHeader("custtype") i do not see getheader method when i do control + soace in eclipse but as per doc at http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletResponse.html its there. I am not sure why getHeader method is not visible here in eclipse.?
How i can i get header from response?
Setting Response Headers from Servlets The most general way to specify headers is to use the setHeader method of HttpServletResponse. This method takes two strings: the header name and the header value. As with setting status codes, you must specify headers before returning the actual document.
You can set response headers, you can add response headers But think about it for a second, then do this exercise. Draw a line from the HttpResponse method to the method's behavior. We did the most obvious one for you. Pretty obvious when you see them all together.
HttpServletResponseWrapper is one particular implementation of HttpServletResponse which gives you a convenient way to wrap an existing response with some logic of your own without having to write a whole new implementation of the interface.
getHeaders(...) methods HttpServletResponse are supported since Servlet 3.0., Before this version you can find only setHeader(...) methods.
For earlier version you can try wrapping the response and implement storing the headers in your wrapper class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With