Win a copy of Murach's Python Programming this week in the Jython/Python 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!