how can we update the date&time without refreshing the page

Hi friends,I have a jsp page. In that there is Date and Time. The date and time should be updated for every one minute without refresh the page(dynamically).Its urgent for meThanksMallik
[221 byte] By [mallik.svha] at [2007-11-27 6:41:09]
# 1

you mean while someone is looking at the page and they dont click anything they will see it change? If this is what you mean, then write a Javascript that does this, not that complicated.

If you mean if someone clicks they see the right time, but then in their browser, it stays like that. And if someone else clicks, they see the current time which might be different that the first user. Then just write a scriptlet with a SimpleDateFormatter that prints out the current date... (or this could be an EL, or custom tag, or whatever)

Chris

mchyzer1a at 2007-7-12 18:10:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

You can achieve this using AJAX. Since using ajax call you can output a string/jsp/xml, in your case make it as a jsp and in your destination page (parent jsp), have a DIV tag and then dynamically load the output jsp into this DIV tag. Using javascript setTimeOut, you can trigger this ajax call for every minute. I would do only this way.

skp71a at 2007-7-12 18:10:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
thanks for ur reply,And can u please send me the sample code
mallik.svha at 2007-7-12 18:10:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

hello friend ru looking at date and time @ client side frm the server side if it is all about the client side date i don't think there is use of AJAX triggers and rendering the view by modifying the dom...

here is an example for you..

<%@ page language="java"%>

<HTML>

<HEAD>

<SCRIPT language="JavaScript">

function startclock()

{

var thetime=new Date();

var nhours=thetime.getHours();

var nmins=thetime.getMinutes();

var nsecn=thetime.getSeconds();

var nday=thetime.getDay();

var nmonth=thetime.getMonth();

var ntoday=thetime.getDate();

var nyear=thetime.getYear();

var AorP=" ";

if (nhours>=12)

AorP="P.M.";

else

AorP="A.M.";

if (nhours>=13)

nhours-=12;

if (nhours==0)

nhours=12;

if (nsecn<10)

nsecn="0"+nsecn;

if (nmins<10)

nmins="0"+nmins;

if (nday==0)

nday="Sunday";

if (nday==1)

nday="Monday";

if (nday==2)

nday="Tuesday";

if (nday==3)

nday="Wednesday";

if (nday==4)

nday="Thursday";

if (nday==5)

nday="Friday";

if (nday==6)

nday="Saturday";

nmonth+=1;

if (nyear<=99)

nyear= "19"+nyear;

if ((nyear>99) && (nyear<2000))

nyear+=1900;

this.document.getElementById("clockspot").innerHTML = "<b>"+nhours+": "+nmins+": "+nsecn+" "+AorP+" "+nday+", "+nmonth+"/"+ntoday+"/"+nyear+"</b>";

setTimeout('startclock()',1000);

}

</SCRIPT>

</HEAD>

<BODY>

<div id="clockspot"></div>

<SCRIPT language="JavaScript">

startclock();

</SCRIPT>

</BODY>

</HTML>

hope this might help :)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-12 18:10:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Thanks Rahul
mallik.svha at 2007-7-12 18:10:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...