Link to home
Start Free TrialLog in
Avatar of dnoelpp
dnoelppFlag for Switzerland

asked on

reloading applets

I am programming an AWT applet and I would like to refresh my browser (Internet Explorer) to show new versions of the same applet. But the browser just shows the cached version and I couldn't convince it to load the new version.

How to refresh applets without clearing the cache?

Avatar of andysalih
andysalih

try this

//**************************************
// Name: Force browser to reload or refresh
// Description:How do I force a reload/refresh from the current page?

//
//
//
// Inputs:None
//
// Returns:None
//
//Assumes:None
//
//Side Effects:None
//**************************************

You can for JavaScript 1.1 use the location objects reload method:
<FORM>
<INPUT TYPE="BUTTON" onClick="window.location.href.reload()" VALUE="Reload">
</FORM>

Failing that you could try a meta tag that doesn't allow the page to be cached so that the following would reload:
<FORM>
<INPUT TYPE="BUTTOM" onClick="window.location.href=window.location.href">
</FORM>

The no cache meta tag needs to be placed in between the <HEAD> and </HEAD> tags:
<META HTTP-EQUIV="no-cache">

Or you could use the meta tag for expires, to always ensure that a newer copy is loaded:
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">

Or you could refresh the page automatically after a delay using the refresh meta:
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">


dunno if it'll work, havent tried it.

cheers
andy
this refreshes a web cam image without refreshing the whole page

browserType = navigator.appName;          
newImage = new Image();
Srvr_IP= "http://127.0.0.1/Image.jpg?";
var dly;
if (browserType == "Netscape") document.write('<IMG SRC="'+ Srvr_IP +'" >')
else     document.write('<IMG SRC="' + Srvr_IP +'" name=ZahidiTV2Web Alt="Zahidi Camera(TV) to Web Server is off. Please Try later." border=1 >');
uniq= 1;
newImage.src= Srvr_IP + uniq;
SnapShot_Loop(4000);
function SnapShot_Loop(delay)


    {
    dly= delay
    if( document.all) loadNewImage();
    setTimeout("SnapShot_Loop(dly)",delay);
}
function loadNewImage()


    {
    Stamp = new Date();
    uniq= Stamp.getTime();
    document.images.ZahidiTV2Web.src= newImage.src;
    newImage.src= Srvr_IP + uniq;
    window.status = "Displaying live video ...";
}
//============================== -->


may work with an applet.

cheers
Andy
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not sure if that (Ctrl-Refresh) works on all versions of IE though.
If it doesn't then maybe think about use appletviewer during testing.
Avatar of dnoelpp

ASKER

Definitively the shortest and best answer of all! Thanks!

The other ones I think will help forcing reloading applets for normal users of the applet, that means, if my applet is deployed and later I have a new version I can't expect normal user pressing Ctrl-Refresh, do you understand? But this is not my problem now.

Thanks for the other experts for contributing anyway.

Cheers!
Insert following within the BODY Tags
onload="startClock()"  
Insert following within the HEAD Tags
<script language="JavaScript">
<!-- hide code
window.onerror = myOnError
function myOnError() {
return true
}
var t = 10
function startClock(){
t--;
document.form1.countdown.value = t;
if (t < 1) {
reloadImg();
t=10;
}
timerID = setTimeout("startClock()", 1000)
}
function reloadImg() {
window.status = "Reloading image ...";
uniq = new Date();
uniq = "?"+uniq.getTime();
newImage = new Image(320, 240)
newImage.src = "http://golum.riv.csu.edu.au/~jpark04/webcam/john.jpg" + uniq;
window.document.images.imgToLoad.src = newImage.src;
window.status = document.images.imgToLoad.src;
}
// end hide -->
</script>
Insert following within the BODY Tags - where you want the image displayed  
<FORM NAME="form1">
<img src = "http://golum.riv.csu.edu.au/~jpark04/webcam/john.jpg" name = "imgToLoad" width = "320" height = "240" border = "1"><br>
Image will refresh in <INPUT NAME = countdown TYPE = TEXT SIZE = 2 VALUE = "">sec
</FORM>
< applet code="JavaCam.class" codebase = "http://golum.riv.csu.edu.au/~jpark04/webcam/JavaCam.class" width="320" height="240" align="middle" > 

<param name="url" value = "http://golum.riv.csu.edu.au/~jpark04/webcam/john.jpg"> 
<param name="interval" value="15">

</applet>

hope all these examples may of use

regards
Andy
Thanks for the points :)
Hi

You may want to try these tags as well, in the past I have found you may have to include both of these tags in order to force a refresh.

<META HTTP-EQUIV="Expires" CONTENT="0">
and
<Meta HTTP-EQUIV="pragma" CONTENT="no-cache">

Darren.
Avatar of dnoelpp

ASKER

Dear objects: The appletviewer is out of question, because I need to test the applet on a secure connection. (That means under really real conditions :-)

I reread the other answers more carefully and me seems that andysalih didn't understand my question completely.

Dear andysalih: Your question answers how to automatically refresh an HTML page. Such a page is never stored in the cache but always reloaded from the server. But this is not the question. I wanted to reload the applet classes for testing and developping. With Ctrl-Refresh you can force Internet Explorer to reload the classes, too. Without the Ctrl only the HTML is reloaded. The same for isond.

The other thing (with the webcam) only refreshes the image, not the applet itself. A good and interesting technique but this doesn't help me because my applet doesn't deal with images.

Thanks for listening.