This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to know if cookies are enabled?

 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
How can we know if cookies are enabled via just the request object we have. I know the way via which we can,
- write a cookie
- read it back and if we do get value it means cookies are enabled
BUT I want to know if there is anyway I can know this information w/o doing these two steps. The reason is, I thought I would write a CookieManager class to add,delete,parse cookies...Now that class would be a stand alone object used in Servlet/JSPs to which I plan to pass a request object and want to have a method in there that says "ifCookiesEnabled()"...you know...
I am not very optimistic about the answer here but I am throwing question...
Nor I am sure how much worth this CookieManager would be...
Thanks!
Maulin
 
Eelco den Heijer
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You already gave the right answer to you own question; that's the way to check cookie-awareness of the client. There is no method in the HttpServletRequest to check for cookie-awareness (not even in J2EE 1.4). Enabling this would require all browsers to support such a query ("Do you support cookies Y/N?") from the server. Anyway, your solution will do the trick anyway
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This means, I can't write a single method in a CookieManager class I have that says, ifCookiesEnabled(HttpServletRequest request)...
Thanks for confirming my belief , Eelco.
Regards
Maulin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic