Hi,
I've found an example of "timer" in MSDN and I've modified it so the
example could work correctly under IE and Netscape versions 4.0 and above.
I hope it will help you.
<HTML>
<HEAD>
<TITLE>Clock Page</TITLE>
</HEAD>
<BODY>
<B>Press buttons to display a clock</B>
<form name="myform">
<P><INPUT TYPE="Text" name="txtClock" value="Clock"></P>
<input type="BUTTON" name="btnStart" value="Start" onclick="startClock
()"></input>
<input type="BUTTON" name="btnStop" value="Stop" onclick="stopClock
()"></input>
</form>
<SCRIPT LANGUAGE=javascript>
var timerID
function startClock(){
// Initial call
document.myform.txtClock.value = "Starting ...";
timerID = window.setTimeout("showClock()", 1000); // 1-second interval
}
function stopClock(){
window.clearTimeout(timerID);
document.myform.txtClock.value = "Stopped!";
}
function showClock(){
// This function actually displays the time.
dt = new Date();
hours = dt.getHours();
minutes = dt.getMinutes();
seconds = dt.getSeconds();
document.myform.txtClock.value = hours + ":" + minutes + ":" + seconds;
timerID = window.setTimeout("showClock()", 1000); // repeat call
}
</SCRIPT>
</BODY>
</HTML>
Best Regards,
Alexander Volodin
nilesh Desai <[EMAIL PROTECTED]>@java.sun.com> on 06.12.2000 07:53:20
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
Sent by: A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:
Subject: Using JSP to dynamically update data continuosly -- creates CPU
usage 100% on NT
Dear Sir/Madam,
I am running HTML PAGE in one frame(frame1) and JSP in another
frame(frame2), My jsp is running continuesly, and then keep calling
javascript which is on HTML page ( frame1), which in turns keep updating
data on frame1 via ID reference on frame1 which is inside <DIV> element.
My problem is after some time CPU usage increses to 100%on client NT
Machine
and also memeory keeps increasing, even after 100 data has been posted, I
keep remvoing data from the frame1 but no change of cpu usage. How can I
solve this problem ?
I am using innerHTML property to keep updating new data on the top of
exisitng data. even when I tried simple example of just adding counter+1 to
html page via JSP, same problem of performance
Looks to me since I am running JSP forever, I am running out of resource
but
I need to run that in while loop forever since I keep getting new data, so
how do I solve this problem?Any help will be greatly appericiated
Regards,
_____________________________________________________________________________________
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets