• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts action in html:img tag not always executed

 
Nicole Seidl
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I'm using the line <IMG SRC="/[project_path]/DisplayImage.do?ImageID=1" /> on multiple jsp pages, to display the image of a chart that I generate using data from a database.
Everything is fine the first time around , but after i navigate to another page using that line, something goes wrong. The new page displays the image of the old chart, not the new one, because the DisplayImage action is not called. If i right-click on the image and choose 'view image', the Display action is called and the correct image is displayed. The correct image is also displayed if i hit F5. I assumed that my browser was caching the image, but after turning off caching nothing improved.
Is there any way of forcing the DisplayImage action to fire, or maybe refresh the page after it's loaded( although that would be a little annoying)?
Many thanks in advance.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This really sounds like a browser caching issue. What browser are you using and what did you do to turn off caching?

In any case, this is an issue you will have to solve because you cannot expect all end users to turn off caching. One strategy would be to append a random value to the end of the URL so that it is always (or at least almost always) unique. So you would generate something like this:

/[project_path]/DisplayImage.do?ImageID=1&random=947483

- Brent
 
Nicole Seidl
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the solution, Brent. I added a time=System.currentTimeMillis() parameter to SRC and it all works perfectly now.

Cheers,
Nico
 
Let me tell you a story about a man named Jed. He made this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic