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?
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.
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