Solved

reloading applets

Posted on 2001-07-31
11
450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Custom Java Application connects to database: Which one of the 20? 4 41
ejb stateless example 2 40
CSV file parsing thru Java 13 39
Chrome and Firefox Java 5 67
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

756 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