Win a copy of Emmy in the Key of Code this week in the General Computing 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

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
 
All of the following truths are shameless lies. But what about this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!