In my JSP page I was using an img tag to load an image in my view page.
Problem :
<html:img page="/myAction.do?id=${aForm.id}" width="400" height="550" style="border:none" /> I was facing problems to load the latest image using above image tag , the browser was retrieving the cached image to me not the latest Below are the steps I was doing
Solution
Apparently I found that it was the imag tag which was causing problem , since the browser was getitng the same link with no change it was loading the image from cahce , the only solution is to have unique link to load that URL by adding a uniquie value at the end of the link t load image , so I started appending the time stamo with the link and now it's working fine I can always see the lates image now , below is what I did in my JSP
Problem :
<html:img page="/myAction.do?id=${aForm.id}" width="400" height="550" style="border:none" /> I was facing problems to load the latest image using above image tag , the browser was retrieving the cached image to me not the latest Below are the steps I was doing
- update the image from my update page
- show the view page to the user , showing him the current image , but current image was not shown to the user instead the last loaded page from the cahce was being loded by browser.
Solution
Apparently I found that it was the imag tag which was causing problem , since the browser was getitng the same link with no change it was loading the image from cahce , the only solution is to have unique link to load that URL by adding a uniquie value at the end of the link t load image , so I started appending the time stamo with the link and now it's working fine I can always see the lates image now , below is what I did in my JSP
<!-- Define date variable-->
<jsp:useBean id="current" class="java.util.Date" />
<!-- Append time at the end of image page -->
<html:img page="/myAction.do?id=${aForm.id}"}&a=${current.time}" width="400" height="550" style="border:none" />
<html:img page="/myAction.do?id=${aForm.id}"}&a=${current.time}" width="400" height="550" style="border:none" />
This will always make it a unique URL for browser hence it will not load the image from cache.