This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

problem with "Expires" header  RSS feed

 
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to set "Expires" header in a jsp file:
[code]
response.setDateHeader("Expires", System.currentTimeMillis() + (1000 * 60 * 60 * 24 * 30));
[code]

i want the page to be expire after one month from current date.

but the when i checked "Temporary Internet Files" folder, the expire column is showing current date not the date of future 1 month.

it work fine if i set the expires header for next 24 days. but any value above 24 days is not working.
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little trap here Make sure that the result of the multiplication is converted to long

 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, now it is working, but i dont understand that since System.currentTimeMillis() is returning long, i expect the final result to be long.

but it is not.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that the result of (1000 * 60 * 60 * 24 * 30) is an int, which actually is negative, because it gets over the max value of an int. So the negative value gets converted to an long. Sounds like a nasty SCJP question
[ November 13, 2006: Message edited by: Satou kurinosuke ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!