• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with "Expires" header

 
hasan khan
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.
 
Christophe Verré
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