• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookies

 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A colleague and I are having a debate about reading cookies:

My friend says that Java should be able to selectively read cookies of a certain domain and path. That is, when a servlet or JSP is reading cookies from the request, it should be able to call a method such as getCookie(String domain) or getCookie(String path) to get only the cookies which match the given input.

My contention is that an HTTP request only transmits the name and value of each cookie, therefore it would be meaningless to filter cookies by anything other than the name and value.


Who is right (I know I am)?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can this debate not be settled by simply examining the javax.servlet.http.Cookie API?
 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, no. Or else I'm missing something. One could point to the fact that methods like getPath() and getDomain() exist and therefore I'm wrong. But if one experimented with these methods, they'd see that these always return null for cookies read from the request. But the API doesn't say this or anything towards what an HTTP request might contain.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps then, you should inspect the actual contents of the HTTP request.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I heartily recommend keeping a copy of RFC 2965 somewhere handy to see what the standard says about what a HTTP request can do with cookies

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic