preventing caching with urlconnection and sun.net.www.content.image.gif
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andre_TheMunchkin
Posted On:   Tuesday, June 19, 2001 12:21 PM

Applet problem: I need to retrieve images that are being updated frequently and therefore I need to disable caching Solution (well...): use URLConnection and turn caching off Solution problem: urlconection.getContent() returns an object that needs be deciphered (it's a gif). i'd rather not write the gif handler code so....??? What doesn't work: the existing content handler provided by sun does work in some browsers (linux netscape, ie5 win98), but generates security exceptions in others (classloader can't find the content/image/gif class, it seems). import sun.net.www.content.image.gif; ..   More>>
Applet problem: I need to retrieve images that are being
updated frequently and therefore I need to disable caching


Solution (well...): use URLConnection and turn
caching off


Solution problem: urlconection.getContent() returns an object
that needs be deciphered (it's a gif). i'd rather not write
the gif handler code so....???


What doesn't work: the existing content handler provided
by sun does work in some browsers (linux netscape, ie5 win98),
but generates security exceptions in others (classloader
can't find the content/image/gif class, it seems).



import sun.net.www.content.image.gif;

...

// open urlconnection to image file

...

gif gi = new gif();

smImg = createImage((java.awt.image.ImageProducer)gi.getContent(urlconnection));




Suggestions?


I've contemplated trying to find, decompile, and reverse
engineer some gif.class code, but that sounds like about
as much of a hassle as translating some C language gif
decoder routines.


anDY

   <<Less

Re: preventing caching with urlconnection and sun.net.www.content.image.gif

Posted By:   Finlay_McWalter  
Posted On:   Wednesday, June 20, 2001 10:04 PM

I figure there's two sensible ways to load images from URLs, neither of which directly uses URLConnection:

  • Toolkit.getImage(URL), which is cached
  • Toolkit.createImage(URL), which is not cached


I don't see why the latter shouldn't work for you. You can also use the former, but you need to call Image.flush() before getting the image a second (or subsequent) time.
About | Sitemap | Contact