LDD Today

Making Web browsers look smarter with Domino 6


by
Dale
Schultz

Level: Beginner
Works with: Domino 6
Updated: 01-Oct-2002

A Web browser is sometimes called a thin client because as a client, it does not have the rich set of features that a Notes client has. One notable deficiency is the ability for a Web browser to display numbers, dates, and times in a format that is appropriate for the user. For example, people in Germany expect to see dates in the order of day, month, and year separated by periods. Similarly a person in China expects dates to be in the order of year, month, and day. Date order confusion between the US format of mm/dd/yyyy and formats that use dd/mm/yyyy order is particularly common, and the effect of interpreting 6/11/2002 as November 6th can be disastrous! In the Notes client, numbers, dates, and times can be displayed using the regional preferences setting of the operating system, but until now, Web browsers could only display such items in whatever format the HTTP server uses.

In this article, we explore Web preferences, a new feature in Domino 6 that lets you set time zone and regional preferences for your Web browser. This article describes what is possible without any configuration on the client side, as well as enhancements that are possible with just a little effort from the user. Information is also provided for those who are interested in taking advantage of the new feature for their application development or server setup. This article is intended for Web browser users, system administrators, and application developers.

Date formatting and time zones: the Web browser vs. Notes client
Web servers send numbers and dates in HTML to browsers simply as text. The Web browser has no way of knowing which text is a date or which text is a number—all it can do is obediently display what the server sent to the user's screen. On the other hand, a Notes client knows that certain elements are dates or numbers and can display them appropriately to the user. The following figure illustrates how a date object stored on a server may be displayed in Notes clients and in Web browsers in different locations.

Date objects in Notes clients and Web browsers

The Notes client determines the desired format from the operating system, so even though the German user in Berlin accesses a server running in New York, the client is smart enough to display it using the German formatting rules and to ensure that the time is displayed in local time. (Of course, this assumes that the operating system of the computer in Berlin is set to German regional settings and that the date being displayed has not been forced into a particular format by the designer.) The Domino Web server in New York sends the date as plain text already formatted using its formatting rules, no matter where the browser is. The Web browsers can only display what is sent to them. As you can see, the Web browser in Berlin not only displays the date and time in an unacceptable format, but also the time is expressed in the time zone of the server!

Clearly, this would be a problem if you wanted to create a Web site to be used all around the world. But Domino 6 solves this problem very nicely at two levels. The first is completely automatic and takes advantage of the fact that modern Web browsers provide a small clue to the server about the user through the HTTP header called HTTP-accept-language. This header provides information indicating configurable locale preferences and is transmitted to a Web server each time the browser makes an HTTP request. For example, "en-US" indicates that the user prefers American English, "en-UK" indicates British English, and "de-DE" indicates standard German. Because there is a strong correlation between language and the rules for formatting dates and numbers, Domino 6 makes a determination as to which format is most appropriate for that user and then serves up the content appropriately.

So without anyone having to make any special configuration changes, numbers, dates, and times are served up in a format that is extremely likely to be what the user expects. As you can see in the following illustration, the Web browser in Berlin suggests German formatting rules and Domino 6 can then format dates using the d.m.yyyy format.

Date/time settings

Web browser language preferences
Most browsers let you define a list of languages that you accept with your most preferred language listed first. To see what your preferred language settings are:

These language preferences do more than specify your preferred language. They also set certain locale preferences, such as date and time formats, associated with each language. The HTTP-accept-language header passes those preferences to the server.

But even with accept-languages defined in the browser, we are not out of the woods yet. The server cannot deduce which time zone the browser is in and as a result, cannot adjust the time component of a date/time to the local time of the user. Just because a person has German as their preferred language does not mean that they are in Germany, and a user with a setting of en_US could be in any one of a number of US time zones. As a result, the Berlin browser still shows the time as 10:23 (server local time) instead of 16:23.

Domino 6 solves this problem at the second level of the solution, which uses persistent browser cookies. Browser cookies allow additional information to be stored on the client computer and transmitted to the server whenever pages are requested from the same domain that created the cookie. For more information, on cookies see Netscape.com for "Cookies" or Microsoft.com for "Cookies: What They Are, Why You Are in Charge."

Simply put, Domino 6 allows Web users to define two cookies that customize their Web experience. One cookie allows the user to customize the formatting of dates, times, numbers, and currency settings; and the second cookie allows the customization of the time zone so that all dates and time can be correctly adjusted to your local time, including correct Daylight Saving Time compensation.

How do I set a cookie to tell the server what I want?
Domino 6 has an automatic, built-in URL that presents you with the pages that can be used to customize your settings. This URL is http://<server name>/$preferences.nsf?OpenPreferences. It looks like a URL for a standard Notes database, but in fact, the $preferences database is virtual and does not exist. The Domino 6 server recognizes this special URL.

You can embed this URL in any Web application, or you can simply provide it as a link to your users. The URL presents a frameset with two options on the left: Time Zone and Regional.

To set your time zone
When you select the Customize option to indicate that you do not want to use the server's time zone, the Time Zone page provides a list of time zones from which you can select your desired time zone. In addition, you can optionally override whether or not Daylight Saving Time (DST) is observed in that time zone. When you click Save, your Web browser creates a cookie and stores it locally on your computer. From then on, dates and times that Domino 6 serves up to that Web browser on that machine will be adjusted for that time zone. Not only can Domino 6 adjust to your time zone, but it also does so using the appropriate Daylight Saving Time rules for your time zone. This is important because many countries switch to DST on different dates.

Time Zone Preferences

Domino overrides the server's time zone settings with your preferences. However, if the application developer enforced a particular date/time format, Domino cannot override the server settings with your preferences.

By creating the Times Zone cookie, the results in the sample scenario improve. The users in Berlin now get the same date formatting and time zone experience in their Web browser as they do in their Notes client.

Date/time settings with time zone cookie

To set your regional settings
When you click the Regional option, the right-hand pane displays a comprehensive list of settings that you can use to customize dates, times, and numbers. Select the Customize option to indicate that you want to override the server settings that it associates with your preferred language. Selecting a locale from the list of locales and then clicking the "Load default preferences for this locale" button sets the default settings for that locale; you can decide if you want to use those default settings or customize them.

Regional Preferences

After you select the Customize option, you can work with the date and time settings and the various number formatting options:

Date, time, number, and currency settings


As with the Time Zone settings, when you click Save, your Web browser creates a cookie and stores it locally on your computer. From then on, all numbers, dates, and times that haven't been forced into a particular format by the designer are sent to the browser on that machine using your regional preferences. In addition, appropriate weekday and month names are used even if the date formatting has been set to a custom setting by the designer. These regional preferences override the locale preferences set when you specified a preferred language in your browser. When you leave either the server or the domain, the Web browser returns to the local preferences that you specified in the browser.

What scope do the cookies have and what information do they store?
In both the Time Zone and Regional Settings panes, a note appears at the bottom of the page indicating if your cookie is effective for the entire domain or just the particular server you are using. The scope of the cookie is determined by a server setting and is described in more detail later in this article. The two cookies expire ten years after being created or updated, so in other words, they are permanent. In addition to the information that is visible in the user interface, each cookie also stores a flag to indicate the validity of the cookie and a cookie version to allow for future enhancements. The Time Zone cookie stores the Daylight Saving Time rule for the selected time zone. The Regional Settings cookie also stores cookie character set information and a code indicating the default number of digits for the representation of years.

Try changing your Web preferences
You can try changing your Web preferences using the Lotus Domino 6 Web preferences demo. This demo lets you experiment with different Web preference settings and see the results in an embedded view on the demo page. Try it out!

Note that if your browser language preference is not set to en-us, you may already have noticed that some dates in areas on LDD are already formatted in your preferred format. When you work with the demo, you can choose a different langauge to see how the formatting changes.

Integrating Web preferences into Web applications
Web preferences were created in a very modular manner so that an application developer can select only the parts of the out-of-the-box feature that are needed. The simplest method is to create a link to the virtual URL: /$preferences.nsf?OpenPreferences either as a hotspot or as Pass-Thru HTML. This will bring users to a frameset that contains both the time zone and regional settings.

You can also create separate links to either or both time zone and regional settings by adding additional parameters to the URL, as follows:

/$Preferences.nsf?OpenPreferences&PreferenceType=TimeZone

/$Preferences.nsf?OpenPreferences&PreferenceType=Regional

Server control for Web preferences
What has to be done on the server to enable this feature? Nothing. By default the feature is enabled, but you can switch the feature off and make some adjustments. You can find the Web Preferences setting in the Server document or Web site document under the Internet Protocols - Domino Web Engine tabs. There you will find a new section called Web User Preferences:

Web User Preferences

There are two settings that you can adjust: Limitations
The following is a list of limitations that affect the Web preferences settings.
Summary
As this article has demonstrated, Domino 6 provides a richer browser experience with regard to appropriate formatting of numbers, dates, and times based on the already present browser accept-language. In addition, times can be adjusted to the user's time zone and default formatting options can be overridden with the aid of two independent browser cookies. Administrators can control the scope of the cookies to be server specific or domain-wide. Application developers can easily add links to access the cookie generation code. The Web user's experience is thus vastly improved with Domino 6.


ABOUT THE AUTHOR
For the past five years, Dale Schultz has concerned himself with all international aspects of Messaging & Collaboration products. When he is not delving into subjects such as code pages, time zones, and translation issues, he can be found working on his model train layout, taking photographs, making biltong, or camping with mosquitos.