File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Image is not reloading on JSP page refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Image is not reloading on JSP page refresh" Watch "Image is not reloading on JSP page refresh" New topic

Image is not reloading on JSP page refresh

Suchith Surendran

Joined: Feb 09, 2012
Posts: 1
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

Joined: Mar 13, 2012
Posts: 2
I have the same problem.
Did you find the answer to your question?
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Might be browser cache problem.

ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Thibaut Lust

Joined: Mar 13, 2012
Posts: 2
Yes, but how to empty the cache of the web browser?
I tried this but it did not work:
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Expires" content="0" />
Jayesh A Lalwani

Joined: Jan 17, 2008
Posts: 2370

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

Joined: Oct 14, 2005
Posts: 18564

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.
I agree. Here's the link:
subject: Image is not reloading on JSP page refresh