Browser time vs Server Time.

B

BigKat

I have a jsp / portlet / webservices application that has realtime
graphing capabilities. The problem I am having is when the machine
that is serving up the jsp / portlet is in a different timezone than
the machine that the browser is running on.

For example, application / server machine is running in New York,
therefore that is where the locale from the request is from. The
browser is being run on a box in California.. The data showing up in
the graph is in the New York timezone. So it appears to be 3 hours
off for the user that has his web browser on his pc in his office.

So now to my question. Has anyone retrieved the browsers machine
timezone. My thought is that the code would have to be in a jsp (some
script language??).

any help would be appreciated.
 
M

Mohan Kakulavarapu

I assume the graph generation code is in your JSP. When the JSP is
being executed
you have to pass the browsers's local time zone in the request or it
must be
previously set either in session or application objects.
If end user is accessing the JSP page by typing in the URL directly, I
don't have a
solution. If the JSP page is accessed through some HTML hyperlink or
through FORM
action, then in this HTML page you can have a hidden field which can be
set
to local timezone using javascript Date Object. This hidden field will
be available
in request object to your JSP. Hope this helps


Mohan Kakulavarapu
Freelance Java Developer
 
N

Nigel Wade

BigKat said:
I have a jsp / portlet / webservices application that has realtime
graphing capabilities. The problem I am having is when the machine
that is serving up the jsp / portlet is in a different timezone than
the machine that the browser is running on.

For example, application / server machine is running in New York,
therefore that is where the locale from the request is from. The
browser is being run on a box in California.. The data showing up in
the graph is in the New York timezone. So it appears to be 3 hours
off for the user that has his web browser on his pc in his office.

So now to my question. Has anyone retrieved the browsers machine
timezone. My thought is that the code would have to be in a jsp (some
script language??).

any help would be appreciated.

Don't use relative times, use absolute times. I.e. do away with the ambiguity of
local timezones, DST etc. and use UTC in all communication between the client
and server. Let the client display the time in whatever way is appropriate,
UTC, local, with or without DST etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top