This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes Browser won't refresh unless you hit F5 - how can I do this in code? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Browser won Watch "Browser won New topic
Author

Browser won't refresh unless you hit F5 - how can I do this in code?

Eric Carlson
Greenhorn

Joined: Sep 27, 2002
Posts: 1
Hi list!
I have a simple logogenerator at http://www.java-technical.com/logogenerator.
This is a servlet which creates the image then returns after displaying it. What happens in practice though is the image is always cached, so just hitting the "Generate" button on that page doesn't show anything new. I know its definitely changing from inspecting the file on the server. The annoying thing is the user can see the latest image at any time with F5. I want to reproduce this behaviour, I tried adding the usual headers in the JSP with no joy :
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma-directive" CONTENT="no-cache">
<META HTTP-EQUIV="cache-directive" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">
Anyone any clues please?
Med Shabe
Ranch Hand

Joined: May 08, 2001
Posts: 84
Have you tried reloading the page with JS?
window.location.reload()
Med.
Jeff Black
Greenhorn

Joined: Aug 02, 2002
Posts: 14
Something to try:
Instead of generating the image and writing it to the file system:
<img src='output.jpg'>
have it generated by a servlet whose response type is image/gif. So in your jsp, do this:
<img src="ImageServlet">
Then setting the cache controls for this response may solve your problem.
Srinivas Saranu
Greenhorn

Joined: Oct 02, 2002
Posts: 7
try
<meta http-equiv="refresh" content="1;URL=jsp page">
vagabond heart
Greenhorn

Joined: Sep 20, 2002
Posts: 2
Hi,
This works for me in jsp page. Try it out
<%
response.addHeader("Pragma","No-cache");
response.addHeader("Cache-Control","no-cache");
response.addDateHeader("Expires",1);
%>
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Browser won't refresh unless you hit F5 - how can I do this in code?
 
Similar Threads
Question on cache control...
Question on NOT Cache....
Jasper Report in Struts JSP
Re: Navigation Restriction
making pages sensetive in struts