473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

cookies sets in one jsp but not another

12
I have this code in two different places in my company's web (test) website.

Expand|Select|Wrap|Line Numbers
  1. int maxAge = 60*60*24*365; // one year cookie
  2. Cookie newCookie = new Cookie("thisWebUser", "Brita");
  3. newCookie.setMaxAge(maxAge);
  4. newCookie.setDomain(".tolltest.com");
  5. newCookie.setPath("/");
  6. response.addCookie(newCookie);
  7.  
When I use this on sampledomain.com/CookieTest/CookieTest.jsp
everything is just fine.

The business website uses a VERY large servlet to manage all the pages in the site. I wanted this code on most of the pages, so I added it to a file called "header.jsp" which is in an include folder.
The page url (not accessable from the outside) is something like this
tolltest.com/homesearch/servlet/HomeSearch

Anyway when I add the cookie code (with different values) to in header.jsp file, the cookie won't set. The code for reading cookies works just fine, and I can see the cookie I set with in CookieTest.jsp

Any ideas what could be going wrong, and more importantly how I might be able to get this to work?

Thanks,
Brita
Nov 1 '07 #1
3 1513
r035198x
13,262 8TB
I have this code in two different places in my company's web (test) website.

Expand|Select|Wrap|Line Numbers
  1. int maxAge = 60*60*24*365; // one year cookie
  2. Cookie newCookie = new Cookie("thisWebUser", "Brita");
  3. newCookie.setMaxAge(maxAge);
  4. newCookie.setDomain(".tolltest.com");
  5. newCookie.setPath("/");
  6. response.addCookie(newCookie);
  7.  
When I use this on sampledomain.com/CookieTest/CookieTest.jsp
everything is just fine.

The business website uses a VERY large servlet to manage all the pages in the site. I wanted this code on most of the pages, so I added it to a file called "header.jsp" which is in an include folder.
The page url (not accessable from the outside) is something like this
tolltest.com/homesearch/servlet/HomeSearch

Anyway when I add the cookie code (with different values) to in header.jsp file, the cookie won't set. The code for reading cookies works just fine, and I can see the cookie I set with in CookieTest.jsp

Any ideas what could be going wrong, and more importantly how I might be able to get this to work?

Thanks,
Brita
I (for one) am afraid I didn't understand all that. What is the cookie supposed to store (as in what problem is it trying to solve)?
Nov 1 '07 #2
Brita
12
The cookie will store a user ID cookie and we take the referrer information and put the user ID and referrer information in a database. People tend to bookmark our web site and we want to be able to go back and find out how people originally come to our web site. We also can then see how often, on average, people come back to our site. We don't care about any personal information about our visiter, I just get the next ID from the database if they don't have a cookie and create a new record.

All of my code worked fine in a little test folder on our test server. When I tried to move the code into the main test website I ran into problems. Since the main servlet controls the whole site I wanted to add the code to an include page which shows up on most all of the public pages. To see how this works in our real web site go to www.tollbrothers.com.

A previous employee tried to do something similar with code in the main servlet but that created more problems than it solved, so I wrote my own code that would work outside the main servlet.

I hope that helps at least a little.

Brita
Nov 1 '07 #3
r035198x
13,262 8TB
The cookie will store a user ID cookie and we take the referrer information and put the user ID and referrer information in a database. People tend to bookmark our web site and we want to be able to go back and find out how people originally come to our web site. We also can then see how often, on average, people come back to our site. We don't care about any personal information about our visiter, I just get the next ID from the database if they don't have a cookie and create a new record.

All of my code worked fine in a little test folder on our test server. When I tried to move the code into the main test website I ran into problems. Since the main servlet controls the whole site I wanted to add the code to an include page which shows up on most all of the public pages. To see how this works in our real web site go to www.tollbrothers.com.

A previous employee tried to do something similar with code in the main servlet but that created more problems than it solved, so I wrote my own code that would work outside the main servlet.

I hope that helps at least a little.

Brita
I can only suggest making sure that it's not because of some funny settings (like cookies disabled, and testing on several browsers e.t.c) but I'll copy this to the Javascript forum as well and see what the experts there may come up with.
Nov 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Brian Burgess | last post by:
Hi all, Anyone see anything wrong with the following: *************************************************************** <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit Dim nAcctNbr Dim...
4
by: Eifion | last post by:
I've noticed a strange problem with setting cookies in ASP when the cookie name you're setting exists in the querystring. The company I work for has many partner sites who link to our site like...
3
by: Mooky Mooksgill | last post by:
I'm writing a reporting application in ASP. I want to have links to a CF app - specifically VeriSign's eCommerce Manager (on VeriSign's server). The links in my app will need current values...
2
by: Keon | last post by:
Hoi Is it possible to use cookies between different domains? For my site I use 2 domains; the first for my global site with ASP en HTML the second is for my forum located on "hyperboards" a...
6
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a...
7
by: Bert | last post by:
I have been reading the post and the FAQ and have been unable to find anything that will help with my problem. First let me say that I am not a web developer, designer and no next to nothing...
1
by: Peter Row | last post by:
Hi, I have a web app, there is only really 1 aspx page (that the user never sees) the rest of the code is done in a DLL that implements HttpHandler. My app (which is a porting job from Vb6...
0
by: Ed Douglas | last post by:
Hiyas, I've been banging my head against a brick wall for the last few days trying to work out why some of my code doesnt work. I have an ASP/ASP.NET application (website) that is the was...
1
by: Johan Goris | last post by:
I have made a website (big part copied) and it works with cookies like : Response.Cookies.Value = blabla ... This works fine when the browser ,internet option , pravacy is set to low. But it...
2
by: Rahul Chatterjee | last post by:
I have a page on my website that sets cookie values and the cookies are subsequently accessed across the rest of the webpages. These cookies are set in the login page and after the user logs in,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.