• 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

Cookie.getMaxAge, encodeRedirectURL

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have asked two questions about Cookie.getMaxAge and response.encodeRedirectURL in the Web Component Certification (SCWCD) forum but it seems hard to get any answers there. But maybe someone in this forum has more knowledge and, particularly, more experience of JSP and servlets development?

These questions are of course not deadly important for me but I never like to leave something behind that I not fully understand when I am studying for an exam.
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cookie.getMaxAge() Answer:

If you look at the properties of the stored cookies on the client machine, you will see the age (or expiry time) is correctly set.

But as per Netscape cookie specification , client is required to send only cookie name and value, hence the browser does not send expiry time for the cookies it sends to server.

Hence, the servlet api on server side defaults the value to the recieved cookies to -1. And, yes, if you get the cookie from cookie array on request object, then cookie.getMaxAge() will always return -1.

About encodeRedirectURL:

I googled with "difference encodeURL and encodeRedirectURL" and found this interesting discussion.
[ October 12, 2004: Message edited by: Susanta Chatterjee ]
 
Jonny Andersson
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gosh! That explains clearly why I always get -1 : ) ... and I found that at least both IE and Firefox never returns the expiration date, only the "required" name and value, when I looked in the header using request.getHeader("COOKIE"). And now I will read through that information about encodeURL and encodeRedirectURL that you linked to.

Thank you very much for good answers!
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic