• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

creating cookies across domains  RSS feed

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet create 2 cookies, then perform a redirect to another URL (on another server) which needs these 2 cookies. My redirect works fine, but the application behind the other URL does not "see" these 2 cookies.
As a test, I wrote 2 simple servlets. One servlet adds the cookies to the response and performs the redirect to a servlet on the same server. The servlet to which I redirect simply looks at all the cookies in the request. The servlet to which the redirect is performed does not find the 2 cookies the first servlet adds to the response. (snippets below)

Any ideas why the cookies cannot be added / retrieved? Any help appreciated.

JDK 1.5
apache-tomact 6.0.10

Code to add cookies:


Code to retrieve cookies from request--never finds the 2 added?

[ February 16, 2008: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Browsers won't send cookies set by one domain to another.
This is by design and has nothing to do with Tomcat.
 
Rolf Johansson
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all URLs and servlets are in the same domain--I denoted the doamin as xxx.com
 
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd test whether the cookies

a) are set correctly (by examining the cookies stored in the browser)

and

b) whether they're sent to the 2nd server (using a tool like the LiveHttpHeaders extension for Firefox)
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a precise statement of the rules cookies are supposed to obey, search for RFC 2965 "HTTP State Management Mechanism"

Bill
 
Run away! Run away! Here, take this tiny ad with you:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!