Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image is not reloading on JSP page refresh

 
Suchith Surendran
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing Jsp struts application. I am generating dynamic jframe chart from my action servlet and save as an image in the webcontent folder.I am displaying the same image in JSP using img tag. But the dynamic image is not getting refreshed though i am refreshing the JSP page. The image file in the webcontent folder is getting reloaded, but Jsp is still showing the old file.

Someone please help me...
Thanks in advance
 
Thibaut Lust
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the same problem.
Did you find the answer to your question?
Thanks
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be browser cache problem.
 
Thibaut Lust
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but how to empty the cache of the web browser?
I tried this but it did not work:
<head>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Expires" content="0" />
</head>
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That will affect the browser caching of the HTML page generated by the JSP. It won;t affect the caching of the image itself. When a HTML page contains an img tag, the browser makes an additional request to the server to get the image. The image itself will have it;s own headers that will control how long the browser will cache it

What you need to do is look into the configuration of your web application server. It will have some way of controlling the header by file type. usually, default configuration for images is to allow browser to cache since normally your images don;t change that often. There are ways to override this behavior. For example Tomcat has an ExpiresFilter. If you have a Apache Load balancer, you could set httpd.conf. If you are using IIS, I believe you can change properties of a folder (might be wrong here.. been a while)
 
Paul Clapham
Sheriff
Posts: 21133
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, assuming you do really have the same problem, the solution would be to make sure that your "dynamic image" reports its last-modified date correctly. If you're using a servlet to display that image then override the getLastModified(HttpServletRequest) method in that servlet to return the time at which the image was created.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic