Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

reloading applets

Posted on 2001-07-31
11
Medium Priority
?
454 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 92

Accepted Solution

by:
objects earned 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…
Suggested Courses

688 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