File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes get Cookie by Name Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "get Cookie by Name" Watch "get Cookie by Name" New topic
Author

get Cookie by Name

SaurabhRc Jain
Greenhorn

Joined: Nov 17, 2011
Posts: 4
Just wondering why there is no method in HttpServletRequest to get a Cookie by passing its name as parameter, like HttpServletRequest.getCookie(java.lang.String name).
Only one method to fetch all cookies "getCookies()".

P.S. I could not find the answer after searching on the web.
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 133

To my view since cookies are saved by web browsers with its name,value and some optional attributes, they can retrieved with the help of objects. so Its not possible to detect by the servlets to detect the specific cookie as a string since web browsers are storing it. With the help of objects we can retrive the entire list as an array. From this array its easy for servlets to get the one you specify.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: get Cookie by Name
 
Similar Threads
change cookie value
why there is no getCookie(cookie name) function?
Why isn't my cookie being set?
Cookies
Cookie