One service made available by DynamoHttpServletRequest is the BrowserTyper. The BrowserTyper service enables an ATG server to identify a visitor’s web browser type and group it into one or more categories. This service (a component of class atg.servlet.BrowserTyper) identifies browsers by the user-agent header field in the request. The BrowserTyper manages a list of browser types, each of which has a name that identifies the browser and a list of patterns that the BrowserTyper uses for matching user-agent fields to browser types.

The list of browser types is found in /atg/dynamo/servlet/pipeline/BrowserTypes. It includes all commonly used browsers, and groups them according to several different attributes, including, among others:

Each browser type is defined as a component in the /atg/dynamo/servlet/pipeline/BrowserTypes directory. These components include two properties: the name of the browser type and the patterns in the user-agent header by which the BrowserTyper attempts to recognize the browser type.

You can add to the list of browser types that the BrowserTyper can recognize. To do this:

  1. Add the names of your browser types to the browserTypes property of the BrowserTyper component in /atg/dynamo/servlet/pipeline, like this:

    browserTypes+=\
            BrowserTypes\MyFirstBrowserType,\
            BrowserTypes\MySecondBrowserType

  2. Create an atg.servlet.BrowserType class component in the /atg/dynamo/servlet/pipeline/BrowserTypes directory for each additional browser type.

  3. The .properties file of the BrowserType component should look like this:

    $class=atg.servlet.BrowserType

    name=MyFirstBrowserType
    patterns=\
              regular-expression-1,\
              regular-expression-2

  4. The patterns property is a list of simplified regular expressions that are matched against the user-agent header for the request. If any of them match, the isBrowserType() method of atg.servlet.BrowserTyper returns true.

  5. The simplified regular expression string has the following form:

    <regexps> = empty |
         <regexps> <regexp>

    <regexp> =
         <base type>
         <type set>
         <regexp>*
         <regexp>+
         <regexp>?
         <regexp>.
         <regexp>|<regexp>
         (<regexps>)

    <base type> =
         any character other than:
           * + ? | ( ) [ ] .

    <type set> =
         [<base types>]

    <base types> = empty |
         <base types> <base type>

    '*' 0 or more times
    '+' 1 or more times
    '?' 0 or 1 time
    '.' Matches any character except \n
    '|' Separates alternatives, e.g. [a | b | c] is 'a or b or c'
    [ ] Join multiple expressions into one expression
    ( ) Group expressions

Browser Caching of Dynamic Pages

Some browsers handle page caching in a way that conflicts with dynamic page requests. ATG’s browser typer marks page requests from those browsers as non-cacheable to override the aggressive caching behavior of some browsers and proxy servers. Because an ATG server does not set a Last-modified header for JSP requests, browsers should not cache results. However, some browsers (such as Microsoft IE 5.0) do cache these pages. Thus, these browsers might display stale content to users on your site. This occurs because of bad caching: instead of re-requesting the JSP, the browser incorrectly displays the cached version. In addition to showing potentially stale content, URL-based session tracking breaks with these browsers.

To prevent browsers from caching dynamic pages, an ATG server sends headers to these browsers with the following:

Pragma: no-cache
Expires: 
date-in-the-past

This behavior is controlled with a special ATG browser type called bad-cacher defined by the following component:

/atg/dynamo/servlet/pipeline/BrowserTypes/BadCacher

This component has a patterns property that defines a regular expression that matches the user-agent header sent by the browser. If the user-agent matches, the Pragma: no-cache and Expires: date-in-the-past headers are sent with each request. By default, Microsoft IE 5.0 is listed as one of these browsers. You can control the list of user-agents where caching is disabled by editing the values of the BadCacher component’s patterns property.

BrowserAttributes Component

ATG includes a request-scoped component at /atg/dynamo/servlet/pipeline/BrowserAttributes that exposes all the known BrowserTyper characteristics of the current request as boolean properties.

This component enables you to create JSPs that display different features, depending on properties like the browser type, so you can include browser-specific or feature-specific code in your pages without resorting to embedded Java tags to test the browser type.

The following example tests whether the request comes from an Internet Explorer browser:

<dsp:droplet name="/atg/dynamo/droplet/Switch">
  <dsp:param bean="BrowserAttributes.MSIE" name="value"/>
  <dsp:oparam name="true">
    Hmmm... you seem to be using Internet Explorer.
  </dsp:oparam>
  <dsp:oparam name="false">
    You aren't using Internet Explorer.
  </dsp:oparam>
</dsp:droplet>

Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices