Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookies Max Age problem

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Still waiting for solution
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic