You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Trond G. Ziarkowski" <tr...@gep-as.com> on 2005/02/16 11:50:51 UTC
Cookies in Tomcat 5.5.7
Hi all!
I'm making a filter that checks that my cookies are set, and sets them
if they are missing.
Code for setting cookie:
String path = request.getContextPath();
cookie = new Cookie(name, value);
cookie.setPath(path);
logger.debug("Setting cookie: " + cookie.getName() + ", " +
cookie.getPath());
response.addCookie(cookie);
Code for checking cookies:
String path = request.getContextPath();
for (Cookie c : cookies) {
String cName = c.getName();
String cPath = c.getPath();
logger.debug("Checking: " + cName + ", " + cPath);
}
When setting the cookie the Cookie.getPath() method returns the path I
have set. But when checking cookies all calls to Cookie.getPath()
returns null regardless of what path I have set. When viewing the
cookies in Firefox the path is the same as when I created the cookie.
Is this a bug?
Has anyone experienced similar behaviour?
Trond
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Cookies in Tomcat 5.5.7
Posted by Tim Funk <fu...@joedog.org>.
All is not lost. The cookie spec says that overlapping cookie names need to
be sent from most specific to least specific. But if you have the same cookie
name across many domains (foo.domain.com vs bar.domain.com) - then things get
a little ambiguous.
-Tim
Trond G. Ziarkowski wrote:
> Thanks Tim,
>
> I was trying to use the same cookiename for different paths in my
> webapp, but since the path is not sent I just have to use different
> cookienames.
>
>
> Trond
>
> Tim Funk wrote:
>
>> getPath() in only useful for setting cookies. The browser only sends
>> the name /value pairing of the cookie back to you. It omits path and
>> expiration.
>>
>> -Tim
>>
>> Trond G. Ziarkowski wrote:
>>
>>> Hi all!
>>>
>>> I'm making a filter that checks that my cookies are set, and sets
>>> them if they are missing.
>>>
>>> Code for setting cookie:
>>> String path = request.getContextPath();
>>> cookie = new Cookie(name, value);
>>> cookie.setPath(path);
>>> logger.debug("Setting cookie: " + cookie.getName() + ", " +
>>> cookie.getPath());
>>> response.addCookie(cookie);
>>>
>>> Code for checking cookies:
>>> String path = request.getContextPath();
>>> for (Cookie c : cookies) {
>>> String cName = c.getName();
>>> String cPath = c.getPath();
>>> logger.debug("Checking: " + cName + ", " + cPath);
>>> }
>>>
>>> When setting the cookie the Cookie.getPath() method returns the path
>>> I have set. But when checking cookies all calls to Cookie.getPath()
>>> returns null regardless of what path I have set. When viewing the
>>> cookies in Firefox the path is the same as when I created the cookie.
>>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Cookies in Tomcat 5.5.7
Posted by "Trond G. Ziarkowski" <tr...@gep-as.com>.
Thanks Tim,
I was trying to use the same cookiename for different paths in my
webapp, but since the path is not sent I just have to use different
cookienames.
Trond
Tim Funk wrote:
> getPath() in only useful for setting cookies. The browser only sends
> the name /value pairing of the cookie back to you. It omits path and
> expiration.
>
> -Tim
>
> Trond G. Ziarkowski wrote:
>
>> Hi all!
>>
>> I'm making a filter that checks that my cookies are set, and sets
>> them if they are missing.
>>
>> Code for setting cookie:
>> String path = request.getContextPath();
>> cookie = new Cookie(name, value);
>> cookie.setPath(path);
>> logger.debug("Setting cookie: " + cookie.getName() + ", " +
>> cookie.getPath());
>> response.addCookie(cookie);
>>
>> Code for checking cookies:
>> String path = request.getContextPath();
>> for (Cookie c : cookies) {
>> String cName = c.getName();
>> String cPath = c.getPath();
>> logger.debug("Checking: " + cName + ", " + cPath);
>> }
>>
>> When setting the cookie the Cookie.getPath() method returns the path
>> I have set. But when checking cookies all calls to Cookie.getPath()
>> returns null regardless of what path I have set. When viewing the
>> cookies in Firefox the path is the same as when I created the cookie.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Cookies in Tomcat 5.5.7
Posted by Tim Funk <fu...@joedog.org>.
getPath() in only useful for setting cookies. The browser only sends the name
/value pairing of the cookie back to you. It omits path and expiration.
-Tim
Trond G. Ziarkowski wrote:
> Hi all!
>
> I'm making a filter that checks that my cookies are set, and sets them
> if they are missing.
>
> Code for setting cookie:
> String path = request.getContextPath();
> cookie = new Cookie(name, value);
> cookie.setPath(path);
> logger.debug("Setting cookie: " + cookie.getName() + ", " +
> cookie.getPath());
> response.addCookie(cookie);
>
> Code for checking cookies:
> String path = request.getContextPath();
> for (Cookie c : cookies) {
> String cName = c.getName();
> String cPath = c.getPath();
> logger.debug("Checking: " + cName + ", " + cPath);
> }
>
> When setting the cookie the Cookie.getPath() method returns the path I
> have set. But when checking cookies all calls to Cookie.getPath()
> returns null regardless of what path I have set. When viewing the
> cookies in Firefox the path is the same as when I created the cookie.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org