Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Struts action in html:img tag not always executed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
    Bookmark Topic Watch Topic
  • New Topic