Caching images in a JApplet

I have a JApplet here:
http://www.jujubees.org/java_photo_album/photoAlbum.html
the code is coming along well but I have one major problem. The images seem to take for ever to download even with a high speed cable connection (so god only knows how long a dial up would take). What technique can I use to make sure the images are being cached in the web browser? Also is there a way to check and see if the browser has cached a certain image? If you want to see the code then I could post it.

I have a JApplet here:
http://www.jujubees.org/java_photo_album/photoAlbum.htm
the code is coming along well but I have one major
problem. The images seem to take for ever to download
even with a high speed cable connection (so god only
knows how long a dial up would take). What technique
can I use to make sure the images are being cached in
the web browser? Also is there a way to check and see
if the browser has cached a certain image? If you want
to see the code then I could post it.Well you could check to see if the images are being cached by printing out the details of your images, byte size and so on. If you want the browser to cache all the images what you could do is feed the location of the images into the applet, with a parameter for instance, then create a thread that iterates over the images in the directory and loads them into a hashtable of some kind. So the rendering would be faster. Or put them into a .jar/.zip, would be faster. You don't have to wait for all the images to load to display the first one.
Unless you are manually coding the images in your code you can be fairly certain that the browser is not going to. Perhaps with advanced browsers like Opera, but even then, no.
See ya
Michael

Similar Messages

  • Cached Image Applet problem

    I've created a SSCE below but I can't seem to find the information I need to
    format the code correctly, and I've already wasted a half hour trying to find the link to the info.
    I found some mentions of links to the info, but when I followed them they were no longer there.
    I would think the FAQ would have something about this but it doesn't appear to....
    Can someone please point me to how to get the code formatted correctly?
    This problem is only with Java 1.6, it works fine with 1.4, 1.5
    In any case my problem is with cached images. It would appear that no matter what I do, I can not
    get ImageIO.read() to give me an updated image. I use the same file name and change the file in the
    use of my GUI.
    To use this code you will have to have an image called gdata.jpg in your "codebase" directory. What
    I do is bring up the applet, then change the image file in my "codebase" directory and then click on the button.
    You'll see commented code in the actionPerformed which loads a image called gdata1.jpg, if this code is there, the new image
    is displayed. The ImageIO.setUseCache(false) appears to do nothing but maybe I'm using it incorrectly.
    Help please....
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.swing.*;
    import javax.swing.JApplet.*;
    import javax.swing.event.*;
    import java.io.*;
    import java.io.Serializable;
    import javax.swing.border.*;
    public class testApplet extends JApplet implements SwingConstants,
    ActionListener
    JPanel testPanel = new JPanel();
    JButton but = new JButton("test");
    URL codeBase,graphURL;
    Image gImage = null;
    Icon iconImage=null;
    // init -- Applet Init
    public void init()
    Container contentpane = getContentPane();
    //Get Server IP information.
    codeBase = getCodeBase();
    try {
    graphURL = new URL(codeBase+"gdata.jpg");
    } catch(MalformedURLException e) { }
    try {
    ImageIO.setUseCache(false);
    gImage = ImageIO.read(graphURL);
    catch(IOException exc) { }
    iconImage = new ImageIcon(gImage);
    but.setIcon(iconImage);
    testPanel.add(but);
    but.addActionListener(this);
    contentpane.add(testPanel);
    // actionPerformed
    public void actionPerformed(ActionEvent e)
    if ( e.getSource() == but ) {
    //If you uncomment out the 3 lines below, changing the name of the image,
    // then it works, otherwise I always get the same image.
    // try {
    // graphURL = new URL(codeBase+"gdata1.jpg");
    // } catch(MalformedURLException ex) { }
    try {
    ImageIO.setUseCache(false);
    gImage = ImageIO.read(graphURL);
    catch(IOException exc) { }
    iconImage = new ImageIcon(gImage);
    but.setIcon(iconImage);
    but.revalidate();
    testPanel.revalidate();
    testPanel.repaint();
    return;
    Edited by: chippr on Sep 13, 2007 10:32 AM

    chippr wrote:
    That's odd. It looks like I'm using the same version jre plugin under windows...jre-6u2-windows-i586-p.exe.
    Which gives me java 1.6_02
    So you changed the image and then hit the button and it worked?Yep.
    >
    hmmmmm, I wonder what the difference is....I'm using firefox under windows, accessing a linux box
    running apache....Same here, except I used appletviewer to test the code on the local machine. Let me upload it to my Linux box (running Apache) and I'll let you know what happens.

  • How to remove cached images in html whe going from one page to another page

    can anybody help how to remove cached images in html pages.i tried with response.setHeader("no-cache") but it is not working

    thanks,
    can u tell me how to make the browser not to cache images.since iam moving from one page which has images, into another page which having few more images both gets overlaped so how to remove images of previous page.
    thanks in advance

  • Open original image instead of cached image

    While the title in itself is rather self explanatory, I'll elaborate somewhat. The current state of opening sent images means opening the cached version - the file name is wrong in that case, and often times the cached image is in wrong format or size, perhaps even compressed too much; Which might not be the preferable action for a large number of people. Could we possibly get a toggle in Options, or even default left-clicking images to opening the actual image, rather than the image cache?

    Hi Gramps,
    Sorry for this late response. I tried the method you pointed to, but it did not work properly, but I got to doing what I wanted to by changing the .css for the classes and also making a new class in the SpryValidationTextField.css etc.and then applying it in the source code among the span tags.
    I have a new question, but will post it separately.
    zabberwan

  • Java + Safari causes page to 'flash' (i.e. reload even cached images)

    Does anyone know if this is able to be corrected or at least why this occurs?
    For Safari 4 beta when Java is active my site http://www.theimagecache.com 'flashes' a lot (i.e.reloads even cached images). Whereas with Java disabled this does not happen and the pages load considerably more quickly.
    I hadn't noticed this before in Safari 3+... but then again... I usually had Java turned off for security reasons so it may have existed then as well.
    But in Firefox 3.1b3, even with Java turned on the pages load very slightly more slowly (i.e. literally only about a fraction of a second more slowly... which is understandable) but they do not 'flash' (i.e. reload cached images).
    Any ideas as to if this can be corrected so viewers that have Java on by default and are using Safari do not see all of this flashing and slower loading?
    Thanks for any input.
    Ron

    Thanks Michael for posting.
    Yes... this Safari beta may be the problem, because even after the images have been cached often many of the images on a new page (that have already been cached) reload.
    Whereas in Firefox 3.1b3 (beta) this does not happen.
    Hopefully they'll get this fixed.
    Thanks again.
    Hope things are going well for you there in Sweden, considering all of the world economic problems.

  • Caching images

    Hi,
    In my scenario, there can be multiple board area for an user.  When an user logs in 5 images for that board area get picked from the database table and cached.  If any other user for the same board area logs in, system should check cache first.  If found, then it should pick from cache or else go to database table to pick the pictures.  I have pasted the code below to show how the pictures are being cached in my application.  Can anyone help me out with retrieving the pictures explicitly from cache.  A code snippet will be very helpful.  Thanks in advance.
    Regards
    Goutam
    Code to cache image
        IF XSTRLEN( <ls_lso_news_st>-img ) > 0.
          CREATE OBJECT lref_cached_response
            TYPE
              cl_http_response
            EXPORTING
              add_c_msg        = 1.
          lref_cached_response->set_data( <ls_lso_news_st>-img ).
          lref_cached_response->set_status( code = 200 reason = 'OK' ).
          lref_cached_response->server_cache_expire_rel( expires_rel = 180 ).
    GUID / UUID functions
          CALL FUNCTION 'GUID_CREATE'
            IMPORTING
              ev_guid_32 = lf_guid.
          CONCATENATE runtime->application_url '/' lf_guid INTO lf_img_st.
          cl_http_server=>server_cache_upload( url      = lf_img_st
                                               response = lref_cached_response ).
        ENDIF. " XSTRLEN
        ls_s_st_new-header     = <ls_lso_news_st>-header.
        ls_s_st_new-body       = <ls_lso_news_st>-body .
        IF <ls_lso_news_st>-link_name IS NOT INITIAL.
          ls_s_st_new-link_name      = <ls_lso_news_st>-link_name.
          CONCATENATE 'http://' <ls_lso_news_st>-link '/' INTO <ls_lso_news_st>-link.
          ls_s_st_new-link = <ls_lso_news_st>-link.
        ENDIF.

    Hi Raja,
    Thanks for your reply, but i guess i was not able to make you understand my scenario.  Multiple user ID can belong to a board area.  Say, for board area CRM, there are 5 user IDs.  From the admin page, news images are uploaded for a board area and they are saved in database table in XSTRING format.  In my application, I check which board area any user ID belong to and get the images from the database table and set them one by one to cache as I have depicted in the code and display using the URL from the cache, but it happens every time.  what i want now is if any user belonging to same board area logs in, it should not go to the database table to pick the image in XSTRING format and set it to cache one by one again.  For that I saved the news link for that board area in another database table.  So application picks all the links from database table and display them from cache.  But if cache time gets replased, image does not get displayed.  I only want to know the process by which I can find out whether a number of images that I uploaded to cache, those are existing or not, i.e. whether caching time has elapsed.
    Please let me know if you have any suitable solution for this.
    Regards
    Goutam Dutta

  • How does Flex cache images??

    To my understanding, in straight HTML the browser caches image files such that upon return visits (all other things being equal) the browser obtains the image from a browser cache rather than re-downloading.
    Does/can flex make use of the same browser cache?   More specifically, if my flex app downloads a large image file; then the visitor closes his/her browser before reopening it and navigating back to my flex app URL where does the same large image file come from, the imageServer again or from some sort of cache?
    For that matter is the flex app itself cached by the browser such that (assuming no changes were made between visits) a return visit to my flex app url does NOT require the re-download of the app from the server (I know HTML has this capability but not sure about the HTML "wrapper page" which launches the flex app).
    Thanks in advance,

    Sorry for being newbie obtuse but are you saying that FP (Flex Project I assume)'s are an Active X (application) and thus IE does utilize its cache for all HTTP based communications???
    If so then as I understand it, the typical Flex Project has an HTML wrapper which then loads the Flex App (I assume using HTTP).  Subsequent Flex<--->Server communications can be HTTP or other format (AMF which I believe BenForta indicated was HTTP "wrapped" as well but at the moment I am less concerned with this).
    As such is the following correct?
    1.)  IE Browser hits HTML page (url) ----> IE checks its cache; If exists compares vs current version on server; If different download from server else load from cache
    2.)  HTML page calls Flex App (using HTTP???) ----> IE again compares Flex App in cache (if exists) vs. server and if same load else download
    3.)  Flex App retrieves image file names via <mx:RemoteObject> ----- I don't see how browser cache can be used here as results not known until after dbase query completes
    4.)  Flex App uses <mx:RemoteObject> results to retrieve large .jpg files  ---- do these "pass through" the browser (and therefore load and/or store in cache) or are they purely "Flex contained" (and if so does flex have any automatic cache or do I have to perhaps store the jpgs in a shared object if I hope to reuse them without a download)???

  • Error : 'no cached images'. What does that mean ?

    I try to import some images in Rapidweaver. But in the previewmode I get this errormessage :
    Error exporting image thumbnail for 'name photoalbum' (no cached image) What does that means ?

    Hi
    Error -50 paramErr  Error in user parameter list
    Can there be any external hard disks - if so How is/are it/they formatted ? Must be Mac OS Extended (hfs) if used for Video.
    UNIX/DOS/FAT32/Mac OS Exchange - works for most but not for VIDEO.
    What this means in Your situation is above me.
    • free space on internal boot hard disk? How much ?
    Video codec
    • streamingDV, AIC etc. (not .avi, .mp4, .m4v, .wmv etc as they are containers not codecs)
    Pictures
    • in what format ? .jpg, .bmp, .tif, else ?
    Audio
    • from where/what format ? iTunes, .avi, .mp3, .aiff, else ?
    The "com.apple.iMovie.plist" file
    Many users has not observed that there are TWO libraries.
    • Library - at root level
    • Library - in user/account folder - THIS IS THE ONE to look into
    from Luke Burns
    I fixed the problem.. but it was very, very strange. I had a very long section for credits and set the line spacing to 1.0.. for some reason this caused it. I removed it, and it worked fine. I put it back, and I couldn't preview or play the video.
    I don't know why that could cause that big of a problem, but it did..
    Klaus1
    You need more free space on your hard drive.
    jonorparkerjon
    After phone support from apple I ended up creating a new project and adding all 117 clips back in individually till I found out what clips flagged and would not allow me to export. I had 3 I deleted and replaced and everything works now 1hr after tedious work....
    Where do Your material come from
    • Camera
    • External hard disk
    • USB-memory
    And all are connected so that iMovie can find it ?
    Yours Bengt W

  • Location of cached images from RSS screenblanker

    Where does the screenblanker cache images from an RSS feed?
    I have been using my own Picasa album as source for the screenblanker for more than a year now. A few days ago, images not originating from my album started to show up. At the moment I am not sure if this was a temporary glitch and these images are now taken from the local  cache, or if this is a permanent problem. As new "alien" images are added constantly, I assume the problem is still present.
    When looking at the raw RSS feed, I can't find any hint for images not from my Picasa album, so I don't think this is Google's fault. Has Apple started to "enrich" the feed with other images someone deems interesting?

    The iPhoto library is a SQLite database and must always be treated as a single entity - you can not ever do anything to the individual components of the database
    Moving it is simple - make sure that the EHD is formatted Mac OS extended (journaled) - this is the required format for the iPhoto library) and is connected using a fast hard wired connection like USB, FireWire, Thunderbolt, etc - and then quit iPhoto and drag the library intact as a single entity to the external drive - hold down the option key while launching iPhoto until the select librarywindogw appears and select the new location - fully test it and once you are positive it is complete and at least one successful backup cycle has run so it is backed up in the new location and working you can trash the old library - test one ore time before emptying the trash
    And verify that your backup is backing up the EHD (by default some like TM do not backup the EHD)
    LN

  • How to cache images retrieved from MDM on Java WebAS

    Hello Colleagues,
    We have a scenario where we are trying to retrieve image records from the MDM using Java APis. Instead of hitting the DB everytime, is there a way to implement caching? For instance, is it possible to cache the images on the java WebAS and return the path of the images instead of returning the byte stream everytime?
    Thanks and Regards,
    Nisha
    Edited by: Nisha NC on Sep 1, 2009 7:35 AM

    Hi Nisha,
    You can use the Class ObjectCache from the Java API.
    For more information please refer to:
    http://help.sap.com/javadocs/MDM71/current/API/index.html
    Hope this helps,
    Idan

  • Background image for a JApplet

    Hi everybody.
    I have a app with some textfields, buttons and some JLabels.
    I want to put a image as background.
    How can I do that?
    Thanks in advance.

    JApplet (and JFrame and any root container) has a Container that it uses to hold everything else, its contentPane. I would create a JPanel and make it my applet's contentPane and then add everything to this contentPane. To show an image on the contentPane/JPanel, I'd simply Google Background image jpanel. I'd get and then read this: [http://faq.javaranch.com/java/BackgroundImageOnJPanel]
    (I've actually bookmarked this page as it gets asked here so often).

  • When I close Firefox and re-open it, all previously cached images are NOT loaded from cache. Why?

    I have a website. Google recommended page-speed and I had previously installed fire-bug. I open Firefox and inspect my website - the home page loads in approx 2 seconds. I may follow a variety of links and all images ( expiry life of 3 months ), css and js files ( expiry life 1 hour ) are cached so that each screen loaded takes less time. If I close firefox get on with other work and then re-open it, its like the images were never cached - what's the point of caching if its ignored?

    Make sure that you do not use "Clear Recent History" to clear the 'Browsing History' when you close Firefox or use cleanup software that clears session data (sessionstore.js)
    * https://support.mozilla.com/kb/Clear+Recent+History

  • Caching images in the client tier

    Hi,
    I've a JSP web application with images.
    In that application, two HTML pages are generated. Each HTML page has the same image im.gif.
    Everytime a navigate from one page to the other, the image im.gif is always loaded from the web server.
    I would like to keep the images cached in the client workstation.
    How can I do that?
    thanks a lote
    apaf

    Well, generally when an image is loaded the path of the image is loaded in the temporary internet files of your browser(IE) and if the location of the image is from the same folder in the web/application server then the browser first checks the Temporary Internet files to get the image. if it finds then it loads the image from there only. This normally happens unless you specify response.setHeader("Expires","-1") or something like that to specify the browser to always take from the web server.
    thanks
    Hi,
    I've a JSP web application with images.
    In that application, two HTML pages are generated. Each HTML page has the same image im.gif.
    Everytime a navigate from one page to the other, the image im.gif is always loaded from the web server.
    I would like to keep the images cached in the client workstation.
    How can I do that?
    thanks a lote
    apaf

  • Don't Cache Image Source URI?

    Is it possible to set an image source to a URI without the app caching the image to disk?  I am streaming a JPEG file that is rewritten every 40ms and I want to refresh the image source to playback like a video but it's only loading the image once
    and never refreshing it. 
    Thanks,
    Gavin
    EDIT I should note that this is my code. I am using the IgnoreImageCache option but it's not doing aything:
    BitmapImage bmp = new BitmapImage(new Uri("http://192.168.94.53/image.jpeg"));
    bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
    IMAGE.Source = bmp;
    Also tried this and it didn't work:
    IMAGE.Source = null;
    BitmapImage bmp = new BitmapImage();
    bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
    bmp.UriSource = new Uri("http://192.168.94.53/image.jpeg");
    IMAGE.Source = bmp;

    Hi im.thatoneguy,
    Try this:
    private void Button_Click(object sender, RoutedEventArgs e)
    image.Source = null;
    BitmapImage bmp = new BitmapImage();
    bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
    bmp.UriSource = new Uri(@"http://10.168.196.118/iis-85.png?" + DateTime.Now);
    image.Source = bmp;
    Tested locally, works fine, adding timespan as GET request can help to refresh.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Media sync (Desktop 6) showing all images on phone, including web cache images??

    When I go to sync the media from my 9700 to my computer it shows my all of the images on the camera - including what appears to be every image that was cached when visiting a web site! I can't find any options (other than to select the media card) to tell it only to look in my photo directory. Any thoughts?

    Never mind - I figured it out.  Thanks.

Maybe you are looking for

  • Replicate customer and vendor from ECC to CRM

    Hi experts, Is it possible to replicate customers and vendors extending the same BP in CRM? If i had one customer in ecc that is a vendor too, can I configure or implement some badi in middleware to replicate changes to the same BP in crm? Best regar

  • Why won't Mountain Lion install on my MacBook Pro?

    Ok, so I've just bought Mountain Lion from the app store for my 2010 13 inch MacBook Pro, it's been downloaded, and now I'm trying to install it. It takes me to the first page, I accept the software license agreement and all that, choose that I want

  • BANK KEY -VENDOR

    Hi In may clients organisation i have created different Bank key for Vendors for eg:salary for SBI vendor 1,ICICI Vendor 2 etc I have created new vendor in the month of Feb 2010 for IDBI and Andhra bank.These accounts were opened by employees in the

  • Sync Contacts from iPhone to Gmail

    I am trying to get it so that the contacts on my phone sync with the contacts in my Gmail. I tried configuring from iTunes and it does not work. I also tried creating a new exchange account and that did not work either.

  • Automatic Downloads doesn't show me Music option

    I bought a new iPhone 4 and at the Settings->Store section it doesn't show me Music and Books option for Automatic Downloads only Apps I checked many times my Apple ID and it is ok and the same happens to me in my iPad. I really apreciate any help Th