Can someone please explain me the use of response.setHeader("foo","bar");method and also response.addHeader("foo","bar"); method...
I am interested in knowing their use only..I know the difference between them...
posted 8 years ago
We set the headers as you know like : response.setContentType("text/html"); ( convinience method made for us)
which can be set as response.addHeader("Content-Type" , "text/html"); or response.setHeader("Content-Type" , "text/html");
But we have bulk of headers which we can reset as per need , for example : Content-Length , Status , Cache-Control etc.
You can check the name of setters ( to know name of headers ,out of which some are set by container in response by default like Server from which response is coming , Date , time of response , Connection type of response etc. )in ServletResponse or HttpServletResponse API.