Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Eric Carlson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried reloading the page with JS?
window.location.reload()
Med.
 
Jeff Black
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try
<meta http-equiv="refresh" content="1;URL=jsp page">
 
vagabond heart
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
%>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!