This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

get Cookie by Name  RSS feed

 
SaurabhRc Jain
Greenhorn
Posts: 12
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!