How to update timer in seconds and display on web page with out reset

[nobr]Hello friends

I have 3 JSP Pages namedlogin.jsp ,first.jsp andsecond.jsp

I got a problem in second .jsp

i am using the code forfirst.jsp as :

<html>

<%@ page import="java.util.*"%>

<title>Just like home page</title>

<IMG src="D:\adp_docs\cooltext53799474.gif">

<head>

<script language="JavaScript">

var dd =new Date();

function UpdateClock()

{

var tDate =new Date();

var l1 = dd.getTime();

var l2 = tDate.getTime();

var diff = l2 - l1 ;

var h_diff = Math.floor(diff/1000/60/60);

diff = diff - h_diff*1000*60*60;

var m_diff = Math.floor(diff/1000/60);

diff = diff - m_diff*1000*60;

var s_diff = Math.floor(diff/1000);

document.frm2.theTime.value =""

+ h_diff +":"

+ m_diff +":"

+ s_diff;

setTimeout("UpdateClock()", 1000);

}

function StartClock()

{

setTimeout("UpdateClock('')", 500);

}

</script>

</head>

<body onload="StartClock()">

<br><br><br>

<form name="frm2" action="second.jsp">

<input type="text" name="theTime" size=30><br><br>

<br>

<center>

<input type="submit" name="sub" value=" SignOut ">

</center>

</form>

</body>

When the user entered in first.jsp using login page , the timer will start and displays total time of access in a text box with updation,the user will go to the second.jsp through this page . This is working fine but when the user coming from the second.jsp to first.jsp the timer is resets and it displays the total accessed time from 0:0:1(starting time).

I don't want to reset the time again when the user coming back to first.jsp

PLZ help me

Thanks in advance..

Sumaduram.[/nobr]

[2524 byte] By [Sumadurama] at [2007-11-27 11:02:08]
# 1

Set an initial time first.jsp, from the server side.

If I recall JSP syntax correctly (I may not) it might look something like:

<script language="JavaScript">

var dd = <%= someNumberOfSeconds %>;

so you'd be storing the number of seconds, not a Date object, so calling dd.getTime() in UpdateClock() would be unnecessary.

On the server side, you would set someNumberOfSeconds on a per-session basis.

paulcwa at 2007-7-29 12:41:21 > top of Java-index,Java Essentials,Java Programming...
# 2

> Set an initial time first.jsp, from the server side.

>

> If I recall JSP syntax correctly (I may not) it might

> look something like:

> > <script language="JavaScript">

>

> ar dd = <%= someNumberOfSeconds %>;

>

> so you'd be storing the number of seconds, not a Date

> object, so calling dd.getTime() in UpdateClock()

> would be unnecessary.

>

> On the server side, you would set someNumberOfSeconds

> on a per-session basis.

Thanks for your replay

I had done this with request.getParameter and hidden types.

it is working fine.

Sumadurama at 2007-7-29 12:41:21 > top of Java-index,Java Essentials,Java Programming...