Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

timestamp

Status
Not open for further replies.

yama

Programmer
Jun 28, 2001
69
SG
Hi, does anyone know how to write a timestamp codes for JSP page so tat my JSP page wont be cached?
thx!
 
If you don't want your jsp cached at all (in other words the client can't even use back) try:
Code:
response.setHeader("Cache-Control", "no-cache");
This should be in the top of your jsp. To be on the safe side you should set this before any content is write to the response object.
Wushutwist
 
hmm...i tried the response.setheader but still the computer cached my pages. is there other way, for example usage of timestamp to force the computer to retrieve info from server instead?
 
What browser are you using, unfortunately even the most current browsers do not "listen" to the Cache-Control header in all cases. There is not much more you can do in the response.

You could try setting the Last-Modified header.
Code:
response.setDateHeader("Last-Modified", System.currentTimeMillis());

If that doesn't sufficiently solve your problem than the only other solution is javascript. I don't want to go into details because there are a number of resources for this on the web. Basically in javascript you could constantly overwrite the current page in the browser's history. So if they press BACK then they return to the last page they requested before entering your application. I don't like this approach because I am a huge fan of the BACK button and it would annoy me as a user to be presented with that. But sometimes you gotta say, "Users be damned, this is the way it has to work!"

Hope you don't come to that. Wushutwist
 
oh..okie, i will try that, thanks for ur help =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top