com.raj.extensions
Class BrowserDetector

java.lang.Object
  |
  +--com.raj.extensions.BrowserDetector

public class BrowserDetector
extends java.lang.Object

Returns Browser information based on HttpServletRequest.getHeader("User-Agent").

 Description   : BrowserDetector
 File Name     : browserDetector.java
 Author        : Raj Bhaskar
 Author Email  : raj_bhaskar@hotmail.com
 Created       : Friday 1 March 2002
 Last Modified : Friday 26 March 2002
 Modified By   : Raj

 Ported from the Weberdev.com PHP Source
 ##browserDetector()
 ##Parses User-Agent string into useful info
 ##Source: Weberdev.com
 ##Author: epsilon7
 ##Author Email: epsilon7@asphyxia.com

 Ported from The Webmonkey JavaScript Source
 ##BrowserDetector()
 ##Parses User-Agent string into useful info.
 ##Source: Webmonkey Code Library
 ##(http://www.hotwired.com/webmonkey/javascript/code_library/)
 ##Author: Rich Blaylock
 ##Author Email: blaylock@wired.com
 

Usage:
Put the class on your classpath and load the bean:
<jsp:useBean id="sniffer" class="BrowserDetector" />
<jsp:setProperty name="sniffer" property="ua" value="<%=request.getHeader("User-Agent")%>' />

 Properties:
 browser   // Netscape, MSIE, Opera
 platform  // Win95, Unix, Windows 98, Mac, PPC, etc.
 version   // MajorVersion.MinorVersion
 majorver  // Major Version (before . in version string)
 minorver  // Minor Version (after . in version string)
 

These can be accessed <jsp:getProperty name="sniffer" property="<<ONE OF THE ABOVE>>" />


Constructor Summary
BrowserDetector()
           
 
Method Summary
 java.lang.String getBrowser()
          gets the browser (Netscape, MSIE or Opera)
 java.lang.String getMajorver()
          gets the major version of this browser
 java.lang.String getMinorver()
          gets the minro version of this browser
 java.lang.String getPlatform()
          gets the platform that the browser is running on
 java.lang.String getVersion()
          get the version of this browser
 void setUa(java.lang.String x)
          stores the User Agent string in the object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserDetector

public BrowserDetector()
Method Detail

setUa

public void setUa(java.lang.String x)
stores the User Agent string in the object

Parameters:
x - the user agent string to store (usually obtained through HttpServletRequest.getHeader("User-Agent")

getBrowser

public java.lang.String getBrowser()
gets the browser (Netscape, MSIE or Opera)


getPlatform

public java.lang.String getPlatform()
gets the platform that the browser is running on

Returns:
Win95, Win98, Unix, PPC etc

getVersion

public java.lang.String getVersion()
get the version of this browser

Returns:
the version of the browser in the form x.x

getMajorver

public java.lang.String getMajorver()
gets the major version of this browser

Returns:
the bit before the '.' of the version, eg if the version was 4.75, then 4 would be returned

getMinorver

public java.lang.String getMinorver()
gets the minro version of this browser

Returns:
the bit after the '.' of the version, eg if the version was 4.75, then .75 would be returned