On Mon, 8 Mar 1999, Robb Shecter wrote:
> The other thing I need is the country, because from that I make date
> output appear in the correct time zone.


Hi Robb,

You should not count on  server's address to find its country -
think about domain names that end with .net, .com, .org wich are not
necessarly from US. (for example IBM's world-wide offices have
all an something.ibm.com address).

Or think about Canada or Russia wich spread over many timezones ...

I had no time to find an equivalent "standard" http way to find browser's
local timezone info, as with Accept-Language HTTP header for
user's language..

Mabe, if no other better solutions, you'll try a hack. Its main idea is to
make browser
side javascript to call server-side servlet through an URI that contains
 client's local time and zone, in a query parameter.


A similar solution mentioned Bill Kayser <[EMAIL PROTECTED]> in this
list.

- Make a servlet called "GrabTimeInfo" that:
   - Gets an input parameter from the request called "TIME=" ...
     wich is supposed to contain browser-side local time-zone info.
   - Extracts somehow time zone information, by parsing it, or
     (if it works) by trying to instantiate some Date class.
   - Saves the obtained time zone info within current session.
   - Sets the response content type to "image/gif"
   - Send back to the browser some gif image, so the user will see
     only a buble  or jumping icon around...

- Write javascript code to be included in your most-accessed index
  pages. It have to:
   - create an localized time string formatted with correct local time
    info, or as Bill Kayser did - just the milliseconds from begin of
    the time.
    (i have doubts about this as I know that some operating systems
     must convert this to the GMT refference)
   - print it within current document image TAG with its SRC
    URI pointing to your servlet, and
   "host:port/servlet/GrabTimeInfo?TIME=<time-info-made-in-javascript>"


So first time someone will access one of the well-placed index pages
(left or top-side menu frames or login screens are good examples) the
servlet will run and save the time info within session.

In other servlets you'll have only to restore the time info from current
session.

Optimisation:
- Check first if time info isnt already saved within current session, so
  "GrabTimeInfo" servlet will not parse the "TIME=" parameter more
  than once.


Drawbacks:
- You need javascript. Works with javascript only.
  You might do the same  with an applet ... not a happy idea...
- You need a dedicated servlet only for this task. That usually bothers
  administrators - the more servlets you give them to install & configure,
  the more confused they become.
- If user disables automatic image loading within its browser,
  this trick will fail..
- Sounds complicated, big solution for a small problem.
  I'd write that only if I have to.. :(.

Advantages:
- If no better or easier way is found, we'll make big bucks selling it.

;-)

Bye,

Cezar Totth                             email:  [EMAIL PROTECTED]
                                        Fax:    (401) 220 33 95
Genesys Software Romania                Phone:  (401) 638 49 44
Stefan Furtuna 169, sect.6
cod 77171, Bucharest
Romania

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to