Terminal Adaptation

Terminal adaptation describes Tammi's capability to adjust itself to allow the same server to serve different devices and user agents.

In spite of standardization efforts, web developers have been struggling with the differences between browser versions from different vendors. In wireless Internet, the situation is even worse with several markup languages and more versatile devices. The advise has been to offer an application based on the smallest common denominator, but this doesn't appeal to most user interface designers.

During waiting for the related worldwide initiatives to mature, Tammi's approach is pragmatic, and has been succesfully applied to provide the same service in (X)HTML (+ its dialects applied by user agents of mobile devices), WML and HDML.

With Tammi, you can benefit from the fact that the syntax of most of these SGML based languages is partially uniform. You only need to take care of the exceptional cases. On the other hand, if you want to serve different browser versions at the ultimate level, there is no limitation - except your time and resources especially regarding testing.

Tammi examines the request from a particular device, matches it with the server configuration, and creates a response adequate for the actual context. You have options e.g. to prioritize content types when more than one of them are acceptable.

MIME Types and Template File Name Extensions

The mappings between MIME media types and the corresponding file name extensions, i.e. suffices, are specified using the same syntax as the mime.types file of the Apache Server. The configuration file, which is part of the core configuration of Tammi, has also the same name.

The file is divided into two sections: 1) definitions of the IANA registered MIME types to be updated occasionally, and 2) additions mostly needed for wireless support above them. With the additions, you can specify either completely new mappings or preferred MIME types for a specific file name extension defined later in the standard section.

The MIME type to apply can be explicitly specified for the current and subsequent requests as a request parameter named x. The value of the parameter is expected to be a file name extension mapped to the desired MIME type. If the x parameter is not specified, Tammi applies one of the default MIME types configured to TerminalFilter. To avoid conflicts with MIME types not accepted by the client, Tammi looks up the best match between MIME types listed in the accept header of the request and the configured default types.

When Tammi receives a template request, a file name extension may have been included in the template file name or left undefined. If an extension is available, Tammi searches for templates with the given extension only and applies a MIME type mapped to that extension. If several MIME types are mapped to the same extension, Tammi prioritizes them according to their order of definition. Types accepted by the client are respected in all cases.

If the file name extension is omitted in the request, Tammi determines the appropriate MIME type and searches for templates with a file name extension mapped to that type. If your application serves clients of one kind only with a fixed template file name extension, you may gain a slight performance improvement by explicitly defining the extension in links and requests.

Terminal Filter Configuration

You can configure MIME types even more precisely to TerminalFilter. This is sometimes necessary as browser and handset vendors don't always seem to provide accurate information about accepted content.

You can configure the following optional features in the terminal filter:

  1. A list of default MIME types, each of which containing optionally
    • an additional qualifier specifying the ext parameter value, i.e. the content type variant
    • a q-value specifying the order of precedence
  2. A list of terminal, i.e. user agent, specific MIME types, each of which containing optionally
    • an additional qualifier nocharset specifying that a charset definition is not to be included in the content type
  3. A list of known user agent variants used as keys for terminal specific MIME types. User agent variants are convenient for optimizing templates - especially layouts - for particular browsers.
  4. Known locations of terminal identification information within requests.

See Javadoc of TerminalFilter for full documentation.

Hands On - Trying Tammi Monitor

Tammi Monitor displays request and response information useful during testing. You can activate it from the link at the bottom of the left hand side menu. Before doing it, please, read the following instructions.

Go through values of these methods:

  • terminal.getContentType()
  • terminal.getDefaultExtension()
  • terminal.getUserAgentVariant()
  • terminal.getContentTypeVariant()
  • request.getHeader(accept)

If you access Tammi from different browsers and emulators, the user agent variant and the accept header of the request vary You can change other values by applying alternate x request parameters, e.g. /x/xhtml, /x/wml (cancel the download if the browser suggests it), or /x/foo. Below are some links for your convenience to test Tammi Monitor: