Solved

reloading applets

Posted on 2001-07-31
11
446 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now