• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cookies Max Age problem

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Thanks a lot in advance.
I am tring to set cookie age using cookie.setMaxAge() in my struts action class but it is not working. if I remove this and add that is working fine.
Please help me?

Regards,
Sree
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


but it is not working



What errors are you seeing? What behaviour are you expecting? Please TellTheDetails.
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot for your reply.
The below code is working independently with JSP in Tomcat,
Please replace K with C

Kookie Kook1 = new Kookie("sred11573", "sreedhar");
cook1.setMaxAge (36500000);
response.addCookie (cook1);
Kookie[] cook2 = request.getKookies();
System.out.println("length--"+cook2.length);

But if I test in WAS5.1 with Struts1.2.9 and Servlet 1.2 then it is not working.
The cookies are not adding so last SOP is not printing as expected.

Hope clear now.
Working in IE 6.0
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your replies.
I tried some thing and found some thing but still surprise what is going on at behind the screen really surprisied and scared.
The following code is perfectly working on WAS 5.1 ,



Strange is if I decrease the Max age value the cookis are not adding to browsers.
But,in tomcat it is taking any value which is lesser than above value also.
Please help me.
I want my cookie should alive only for 1yr but with above it is 1.6 years.
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still waiting for solution
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont see anything in the kookie RFC or the servlet API that prescribes a maximum Max-Age value. Perhaps your browser is rejecting or deleting the cookie for some other reason? Is there a possibility that some other code is modifying the Max-Age?

How are you determining that the browser is not getting the cookie?

Bill
[ October 02, 2008: Message edited by: William Brogden ]
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using broswer options I am seeing that cookie. Which is very easy in firefox.
But still my problem as is.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic