Solved

reloading applets

Posted on 2001-07-31
11
449 Views
Last Modified: 2013-12-29
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?

0
Comment
Question by:dnoelpp
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 3

Expert Comment

by:andysalih
ID: 6337057
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
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6337062
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
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6337067
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6337073
Try Ctrl-Refresh.
0
 
LVL 92

Expert Comment

by:objects
ID: 6337077
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.
0
 
LVL 3

Author Comment

by:dnoelpp
ID: 6337082
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!
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6337083
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>
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6337085
< 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
0
 
LVL 92

Expert Comment

by:objects
ID: 6337088
Thanks for the points :)
0
 

Expert Comment

by:isond
ID: 6337090
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.
0
 
LVL 3

Author Comment

by:dnoelpp
ID: 6337099
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question