• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Tough Cookie

 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Asked by Marilyn in a nitpick:

Do you want a new Cookie or do you want to change the original Cookie that already exists?

Well, I want to change the cookie that already exists, but cookie.setValue(String) doesn't change the value of the cookie. So I just made a new one. Now that works, I just don't like the fact that I can't change the value.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carol,

I tried to make my cookie code 'elegant' by trying to change a cookie directly. No luck. The solution I came up with is to loop through all the cookies until I find the right one and then change the value.

Mark
 
Carol Murphy
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I thought I was doing the same thing, iterating through the Cookie Array until I found the one with the right name and changing the value............ but the value doesn't change. When I simply create a new Cookie with the same name but give it a different value, I get the result I was after. Only my code isn't working quite right yet. The back button allows the user to get right back into the app even though the cookie value isn't right. Perhaps each jsp needs to check the cookie value before it displays?
I'm at the Apple store in WC. I have to work 3 til midnight tonight. We're doing a remodel................... I will contemplate this while I work!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After you change it, do you add it again?
 
Carol Murphy
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. When the logout button is clicked, the cookie gets changed to something that should cause the login page to display. But when I check the value in Firefox's tool menu, the value doesn't change when I use setValue(). It does change when I just make a new cookie.
I think it may have something to do with scope. When using setValue(), the code is inside the for loop. Perhaps that's what's causing the problem. I'm too fried to check it out now. I'll look at it tomorrow.
 
Carol Murphy
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marilyn de Queiroz:
After you change it, do you add it again?



Duh..........No. If the for loop finds the one I'm looking for and changes its value, I shouldn't have to add it again, should I? Is this simply a scope issue after all? The value is only changed inside the for loop unless I explicitly add the change to the ArrayList? Hmmmm. Must go check this out.
(We need a DOH! graemlin)
 
Carol Murphy
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the value wasn't changed where I thought it would be changed because I wasn't applying the change to the actual thing that gets passed back to the jsp. Hmmmmmmm. Not exactly a scope issue, but I think I get what wasn't working before.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic