Home arrow static arrow Java Programming [Archive] - Multiple images from static URL
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Multiple images from static URL
This topic has 7 replies on 1 page.

Posts:13
Registered: 5/12/04
Multiple images from static URL  
Jun 28, 2004 1:03 PM



 
I am currently writing an applet that grabs radar images from a static URL. The image on the URL is updated every 15 minutes. I have a timer that will grab the image every 15 minutes and put it in an image[] array. Eventually I will be looping these images, and let the user define how far back to loop and how fast the loop is. Right now, though, every image it grabs is the same as the very first one. For testing purposes I have the URL currently set to an online panda cam with a timestamp (so I dont have to wait 30 minutes every build to see if it works on the radar URL). If I start the program at 12:47:51(timestamp on webcam) , it grabs a new image every 10 seconds. After a few minutes I have an array of images with the timestamp 12:47:51, every image is identical.
 

Posts:24,036
Registered: 2/3/03
Re: Multiple images from static URL  
Jun 28, 2004 1:12 PM (reply 1 of 7)



 
It very likely has something to do with how you're grabbing the image and putting it in the array.
 

Posts:13
Registered: 5/12/04
Re: Multiple images from static URL  
Jun 28, 2004 1:23 PM (reply 2 of 7)



 
well, I have the url
"url"
and the image[] array
"imageArray[x]"

in the actionPerformed for the timer:
imageArray[x] = getImage(url);


Currently I just have a button to step thru the images.
				backg.drawImage(imageArray[counter],0,0,radarWidth,radarHeight,Color.white,this);


Just to see if that worked I loaded the array with images from different URLs, and I was able to display them all without problem. Just when I use the static URL do I get the problem of the repeated image.
 

Posts:14,142
Registered: 99-04-02
Re: Multiple images from static URL  
Jun 28, 2004 1:30 PM (reply 3 of 7)



 
How are you getting the image, exactly..? Cuz likely whatever you are doing is caching the image and if the URL is the same, it's just getting the image from the cache.

One way to do it is to add an used parameter to the URL query string with a changing value every time to make sure the URL is different. The server most likely will ignore this extra parameter.
 

Posts:13
Registered: 5/12/04
Re: Multiple images from static URL  
Jun 28, 2004 1:37 PM (reply 4 of 7)



 
the url I'm using is

url = new URL("http://image.weather.com/web/radar/us_htl_closeradar_large_usen.jpg");

What could I add to that that could be ignored? Would it be possible to either empty cache or get it to ignore cache?
 

Posts:14,142
Registered: 99-04-02
Re: Multiple images from static URL  
Jun 28, 2004 1:41 PM (reply 5 of 7)



 
Well, it could be cached in a firewall or something.

If you make the URL:

http://image.weather.com/web/radar/us_htl_closeradar_large_usen.jpg?q=XXX

Where you substitute XXX with the value from System.currentTimeMillis(), for example, it'll still get the image, but the URL will be different, thus not cached.
 

Posts:13
Registered: 5/12/04
Re: Multiple images from static URL  
Jun 28, 2004 1:43 PM (reply 6 of 7)



 
Thank you! I didn't even know that was possible until your post.
 

Posts:14,142
Registered: 99-04-02
Re: Multiple images from static URL  
Jun 29, 2004 12:02 PM (reply 7 of 7)



 
although, it's interesting cuz if it's really the weather server that you are using, the server should be sending no-cache headers (or short expire time headers) with it.
 
This topic has 7 replies on 1 page.