• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Refresh problem in applet

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a problem with my applet. My applet load the image in the applet using double buffering with name image.jpg (first page). This image is sotre on the server and picked by my applet. Then i give the user, facility to crop the image and add color to the image if he finds it neccessary. This is done by calling different applet. After this, user has to save the image, which is again saved with the same name on the server, i.e. image.jpg.
But when i again try to open the image loading page( first page), it displays me the old image only within the applet and not the new modified image. I guess, this is happening because browser has cached my previous first page applet. I can only see the modified image when i click on the refresh bustton on the browser.
Is there any solution for this, so that user shouldnt be doing refresh each time he modified the image?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think it's the browser caching the image, because the Sun JVM uses its own networking code (which may have a chache, too, I'm not sure). Is the server actually accessed the second time? Maybe it is, but responds with a 304, signalling that it thinks the file hasn't changed.
 
Yogesh Dhond
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok !! something I am getting in this>>.
I have one more problem ... can i call another applet from first applet
and pass some of the variables of first applet to this called applet.
And does it mean that i m loading next applet within the same first applet?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by one applet calling another applet? Are those on the same web page or on different pages?

There are ways of getting applets to communicate with one another, but it's more complicated than a method call from one object to another.
 
Yogesh Dhond
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
currently my applet is communicating with PHP/html . So i get data from
php file which passes me param names containing photoimage.jpg with its path.
After this, my applet is loaded which takes those param names and picks the
photoimage from stored location mentined in the path. This applet has save button inorder to save the image. Also there are html buttons like "Proceed" and "Edit Image".
If user wants to edit image for enhancements, he clicks on the "Edit Image" link which loads another applet in the same browser window which helps the user to perform photoimage enhancement task like changing color and giving effects. Here also within an applet theres is save button which saves the enhanced image. The new enhanced image is also saved as photoimage.jpg in the same location replacing old file.
So when user comes back to the first page, using html link, the first applet is loaded. But the image shown here is still the old unmodified photoimage.jpg and not the new. If i check the image which is saved on the server in the path, the new modified image is shown.
If i close the browser and then start the operation all over again, then this time the new image is loaded, which is quiet obvious.
Somehow i want the browser to load the new image wthout refreshing or closing it.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which mechanism does the applet use to access the image? HttpUrlConnection?

It goes back to what I said in my first post: either the JVM may be caching the image, or the web server may be signalling that it's unchanged. You should determine which of these it is.
 
Yogesh Dhond
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using following
java.net.URL imgURL =test.class.getResource(path);
if (imgURL != null)
{
return new ImageIcon(imgURL);
}
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using getResource will indeed cause the image to be cached (kind of), because the classloader will load resources only once, and then never again.

You need to switch to using HTTP more directly to retrieve the image. The Applet FAQ talks about that.
 
Yogesh Dhond
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestion...
currently we are now saving the image with different name so that, theres
no caching problem. Also using http instead of direct file resource.
I am not finding the proper topic to search in the link, you have provided.
 
reply
    Bookmark Topic Watch Topic
  • New Topic