server clock time

hi,

i have problem regrding clock time display..

i have an application( front end jsp, database used mysql, tomcat server) running on a client system..fine....

in this application whenever client logs in login time( ltime when user logs in not when activity is started) is displayed and the time taken is from server's clock...

i have one more item calledstart time (when activity is started)&end time (when activity ends)to record time of the user for checking how much time he is using the application....to know the end time i use user defined timer which increments ..... but tthe problem is when u change the client s system time that change is reflected in my application's end time & strat time but login time is not affected... i dont want my application s time to be affected when u change the client system time.... i want my apllication to follow server time

uuuuuuuufffffffffffffffffffff...... can anybody help me.....

thanks in advance

[1026 byte] By [gania] at [2007-10-3 0:30:04]
# 1

my code goes here..............

<SCRIPT language="JavaScript">

function startclock()

{

var thetime=new Date();

var nhours=thetime.getHours();

var nmins=thetime.getMinutes();

var nsecn=thetime.getSeconds();

var AorP=" ";

/*if (nhours>=12)

AorP="P.M.";

else

AorP="A.M.";*/

if (nhours>=25)

nhours-=24;

/*if (nhours==0)

nhours=12;*/

if (nsecn<10)

nsecn="0"+nsecn;

if (nmins<10)

nmins="0"+nmins;

if (nhours<10)

nhours="0"+nhours;

document.clockform.clockEnds.value=nhours+":"+nmins+":"+nsecn/*+" "+AorP*/;

setTimeout('startclock()',1000);

gania at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
there is a logical mistake..... no syntax error.. application is running absolutely fine
gania at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
can any body help me........
gania at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
you are not getting the server time when you use javascript..
jgalacambraa at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
exactly, am not getting...............
gania at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
it is because javascript runs on the client browser and not on the server.. there is no interaction between the server and the client from what you have done.
jgalacambraa at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
i completely agree with u... i tried this servlet which is called when a jsp application is invoked now it is taking server time only......my collegue Mr. Hal solved the case.... thanks for ur suggestion
gania at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
ok hope that solves your problem (',')
jgalacambraa at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Hi,Can yo please give help to get the server time.I am not able to get any guidance to get the server time.in my work i need to just get the server time.Any methods or packages to be imported for that?.Expecting your reply.Thanks in advance,R.Ramesh.
rameshra at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

Hi Mahes,

For this case you have to save server timing in any text box when every JSP page is created and calculated according to that.

You can fetch server timing by writing java code in scripts like

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

<%

Date a = new Date();

%>

This variable have server date <%=a%>

KamleshSDhamia at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11
I am in the process of designing and developing a test engine application for my organisation using jsp and servlet. This is my first application parse using this technology. Can any body give me a clue or sample code?
frankfurta at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12
Hi gani,Can yo please give help to get the server time.I am not able to get any guidance to get the server time.in my work i need to just get the server time.Any methods or packages to be imported for that?.Expecting your reply.Thanks in advance,R.Ramesh.
rameshra at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13
using java.util.date or the Calendar class will help you get the server time
jgalacambraa at 2007-7-14 17:23:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...