Cookie usernameCookie = new Cookie ("username", attributeUsername);
usernameCookie.setMaxAge(24*60*60);
response.addCookie(usernameCookie);
A cookie is created in the server in this way and it is added to the HttpServletResponse .
Then why is it that , a HttpServletRequest Header contain cookies ??
Cookies are transmitted per request, example use case:
Set-Cookie; this is whatresponse.addCookiedoes.Cookiecontaining a list of all matching cookies (including cookie A)Cookies are part of the HTTP protocol. Wikipedia provides a fine overview: http://en.wikipedia.org/wiki/HTTP_cookie