All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class WebSite.Servlet.Client

java.lang.Object
   |
   +----WebSite.Servlet.Client

public final class Client
extends Object

The Client class implements WebSite client-related data items. It is purely a static class, it cannot be instantiated.

Browser Capabilities

This class has several methods which return properties that describe properties of the client Web browser. These methods use the User-Agent: header in the HTTP request to look up named browser properties from a file named browscap.ini. If the browser version string in the User-Agent: header matches a section name in browscap.ini, the name-value pairs in that section form the browser properties. Otherwise, the default section is used, if any. If the User-Agent string does not match a section in the file, and if there is no default section in the file, String properties return "UNKNOWN", int properties return -1 and boolean properties return false. Examples:
         //
          // Using instrisic method in Client
          //
          if(Client.doesFrames()) {
              // do the frame flavor
          } else {
              // do the non-frame flavor
          }
          //
          // Equivalent, accessing the browscap data by name
          //
          if(Client.getBrowserCap("frames").equalsIgnoreCase("true") {
              // do the frame flavor
          } else {
              // do the non-frame flavor
          }
          //
          // Get a browser property that is not supported 
          // intrinsically by class Client
          //
          if(Client.getBrowserCap("crawler").equalsIgnoreCase("true") {
              // It's a crawler/spider...
          } else {
              // It's not a crawker/spider...
          }

browscap.ini

The browscap.ini file has the syntax of a Windows INI file, and is compatible with the browscap.ini file used with Microsoft Active Server Pages (ASP). A browscap.ini file is shipped with the WebSite.Servlet SDK. The file is kept in the WebSite\java\bin directory.

You can download a community-maintained and frequently updated browscap.ini from the CyScape site, or get the latest Microsoft browscap.ini from the Microsoft IIS site. Note that there is an internet shortcut in the WebSIte\java\bin directory that leads to the last known location of the CyScape browscap.ini page.

You can also make your own browscap.ini, though this is a lot of work that others have already done. See the next section on how to extend a ready-made browscap.ini file to suit your needs.

Custom browscap.ini

If you use the Microsoft browscap.ini file, you can easily extend and/or customize the available information without editing each update you get from Microsoft. You can create a custom browscap.ini file, called browscap-ex.ini. Information in this file overrides that contained in browscap.ini.
Note: Starting with this release, you can get to any capability listed for the browser via the Client.getBrowserCap() method. This allows you to use new capabilities as they come into use and/or as you define them, though the syntax may be more cumbersome. Most of the common capabilities are encapsulated by methods in class Client (for example, doesTables()).

See Also:
Form, Request, Response, Server, Session

Method Index

 o doesActiveXControls()
Returns true if the browser supports ActiveX/OLE controls.
 o doesBgSounds()
Returns true if the browser supports background sounds.
 o doesCookies()
Returns true if the browser supports cookies.
 o doesFrames()
Returns true if the browser supports frames.
 o doesJavaApplets()
Returns true if the browser supports Java Applets.
 o doesJavaScript()
Returns true if the browser supports JavaScript.
 o doesTables()
Returns true if the browser supports tables.
 o doesVBScript()
Returns true if the browser supports VBScript.
 o getAuthMethod()
Gets the authentication method if it appears in the HTTP request.
 o getAuthPass()
Gets the authentication password if it appears in the HTTP request.
 o getAuthRealm()
Gets the authentication realm if applicable and if it appears in the HTTP request.
 o getAuthUser()
Gets the authenticated username if it appears in the HTTP request.
 o getBrowserCap(String)
Returns a string containing the value of the named "capability" for the browser that issued the request.
 o getBrowserMajorVer()
Returns the integer major version of the browser.
 o getBrowserMinorVer()
Returns the integer minor version of the browser.
 o getBrowserName()
Returns the short/generic name of the browser.
 o getBrowserVersion()
Returns the version string for the browser.
 o getHostname()
Gets the network host name of the HTTP client (if available).
 o getIP()
Gets the IP address of the HTTP client
 o getPlatform()
Returns the name of the platform on which the browser is running, for example "Win95", "MacPPC".
 o getUserAgent()
Gets the product name and version of the client (browser) that issued the request.
 o isBeta()
Returns true if the browser is a beta version.
 o onWin16()
Returns true if the browser is running on the 16-bit Windows OS.

Methods

 o getHostname
 public static native String getHostname()
Gets the network host name of the HTTP client (if available). Typically this will return null as we recommend against using DNS reverse lookupson incoming requests.

 o getIP
 public static native String getIP()
Gets the IP address of the HTTP client

 o getUserAgent
 public static native String getUserAgent()
Gets the product name and version of the client (browser) that issued the request. Not generated by some browsers. null if no User Agent: was present.

 o getBrowserCap
 public static native String getBrowserCap(String name)
Returns a string containing the value of the named "capability" for the browser that issued the request. This method allows you to get any capability listed for the current browser, by name. This is useful for capabilities not covered by the other client property access methods in this class (such as doesFrames()).

 o getBrowserName
 public static native String getBrowserName()
Returns the short/generic name of the browser. For example "Netscape", "IE", "PIE" (Pocket IE), "Power Browser" (Oracle).

 o getBrowserVersion
 public static native String getBrowserVersion()
Returns the version string for the browser. For example "1.5j"

See Also:
getBrowserMajorVer, getBrowserMinorVer, getPlatform, isBeta
 o getBrowserMajorVer
 public static native int getBrowserMajorVer()
Returns the integer major version of the browser. For example, if the browser's version string is "1.5j" the major version is 1.

See Also:
getBrowserVersion, getBrowserMinorVer, getPlatform, isBeta
 o getBrowserMinorVer
 public static native int getBrowserMinorVer()
Returns the integer minor version of the browser. For example, if the browser's version string is "1.5j" the minor version is 5.

See Also:
getBrowserVersion, getBrowserMajorVer, getBrowserMinorVer, getPlatform, isBeta
 o getPlatform
 public static native String getPlatform()
Returns the name of the platform on which the browser is running, for example "Win95", "MacPPC".

See Also:
getBrowserVersion, getBrowserMajorVer, getBrowserMinorVer, isBeta
 o isBeta
 public static native boolean isBeta()
Returns true if the browser is a beta version.

See Also:
getBrowserVersion, getBrowserMajorVer, getBrowserMinorVer, getPlatform
 o doesFrames
 public static native boolean doesFrames()
Returns true if the browser supports frames.

 o doesTables
 public static native boolean doesTables()
Returns true if the browser supports tables.

 o doesCookies
 public static native boolean doesCookies()
Returns true if the browser supports cookies.

 o doesJavaApplets
 public static native boolean doesJavaApplets()
Returns true if the browser supports Java Applets.

 o doesJavaScript
 public static native boolean doesJavaScript()
Returns true if the browser supports JavaScript. Warning: Microsoft Internet Explorer purports to support JavaScript with their "JScript" language, but the implementation may not be complete. Verify your JavaScript on IE before going to production.

 o doesVBScript
 public static native boolean doesVBScript()
Returns true if the browser supports VBScript.

 o doesActiveXControls
 public static native boolean doesActiveXControls()
Returns true if the browser supports ActiveX/OLE controls.

 o doesBgSounds
 public static native boolean doesBgSounds()
Returns true if the browser supports background sounds.

 o onWin16
 public static native boolean onWin16()
Returns true if the browser is running on the 16-bit Windows OS.

See Also:
getPlatform
 o getAuthMethod
 public static native String getAuthMethod()
Gets the authentication method if it appears in the HTTP request. Usually Basic. Otherwise, returns null.

 o getAuthRealm
 public static native String getAuthRealm()
Gets the authentication realm if applicable and if it appears in the HTTP request. Otherwise, returns null.

 o getAuthUser
 public static native String getAuthUser()
Gets the authenticated username if it appears in the HTTP request. Otherwise, returns null.

 o getAuthPass
 public static native String getAuthPass()
Gets the authentication password if it appears in the HTTP request. Otherwise, returns null.


All Packages  Class Hierarchy  This Package  Previous  Next  Index