Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Image is not updating properly  RSS feed

 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm creating an image depends on user's input. This functionality didn't work properly in IE. Because My IE displays the image only from cache not from server. I used bellow code to prevent Image store in browser's cache.

I doesn't have any problem in firefox browser But I don't know Why the problem happens in IE. Please anyone tell me.
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vinoth I had a similar problem. Now I need some details from you. First of all I think you are creating the image in a servlet. Also the page on which you place the image, is that a dynamic page?? If yes then you should append the current time as parameter to the src property of the img tag so that it is different each time the page is generated on the server side. I am talking of something like this (sorry for using expression there )

<img src="imageGeneratingServlet?time=<%=new java.util.Date().getTime() %>" />

Now the servlet generating the page will receive this parameter when the image is rendered. But you can ignore it. But if you have a static page i.e. HTML, then you will have to set the src property of the img tab from javascript and again add a dynamic parameter to it

<img id="myImg" src=""/>

document.getElementById("myImg").src = "imageGeneratingServlet?time="+new Date().getTime();

[Edit: removed a problem with <img> tag]
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The response headers must be set on the response of the image, not on the response of the page where the images are loaded in. This is a common mistake.

Once done that, clear the browser cache once again before testing.
 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit Garg,
Your suggestion help me a lot. I'm creating a dynamic page. Thanks for your suggestion. I added time property in

<img src="imageGeneratingServlet?time=<%=new java.util.Date().getTime() %>" />
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vinoth great to hear that I could help. You need to edit your post to remove the problem with the <img> tag as I did earlier :lol:
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are checkboxes with several options right under the message editor. Have you noticed them? Do you (as being webdevelopers) actually understand what each of they do?

At any way, I would say, why would you create a whole Date object and getting only its time instead of just calling System#currentTimeMillis()?

Last but not least, this is not a solution, but a workaround.
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:There are checkboxes with several options right under the message editor. Have you noticed them? Do you (as being webdevelopers) actually understand what each of they do?


Ohh yes. I didn't notice them earlier.


Bauke Scholtz wrote:At any way, I would say, why would you create a whole Date object and getting only its time instead of just calling System#currentTimeMillis()?


I never thought of that


Bauke Scholtz wrote:Last but not least, this is not a solution, but a workaround.


Well I told what I used when I faced a similar problem. So just relax. I know what you told was also correct. But may be he was not able to understand it. So just chill ...
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Relax? Chill? Are you so stressed of my reply? Sorry about that? I just say what I know/think. Don´t take it on the man or so.
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:Relax? Chill? Are you so stressed of my reply? Sorry about that? I just say what I know/think. Don´t take it on the man or so.


No problems buddy
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!