Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't there a getCookie(String) method in the HttpServletRequest? [closed]

As a software consultant, I have been using the Servlet API since the dawn of the man, but I always want to know, why there isn't a getCookie(String) method in the HttpServletRequest?

The API only defines the getCookies() method wich returns an array of Cookies, so if you are looking for some specific cookie at the Servlet level you have to iterate over the whole array, having a getCookie method would be great, don't you think?

like image 449
Ismael the angry developer Avatar asked Aug 07 '11 17:08

Ismael the angry developer


1 Answers

Pretty sure, no one here can provide a final answer to your question, but you should keep in mind that the Servlet API is a fairly low-level thing. It provides basic abstractions around the HTTP protocol, that's why the whole world uses libraries providing a higher degree of abstraction (spring, struts, jsf, lift, etc.).

BTW: The cookie name must not necessarily be unique, a cookie is identified by its name and path.

like image 149
home Avatar answered Nov 08 '22 15:11

home