| Detection Script |
In order to support a wider range of browser/JVM combinations, as well as provide detailed and reliable feedback for browser/JVM combinations that aren't supported, a detection script must be called prior to running any of the Appletfile applets. This script will determine the configuration of the user's browser/JVM and set a session variable to reference the correct type of applet archive to use.
Using the Detection Script in ASP applications
Using the Detection Script in ColdFusion applications
Support for Perl, PHP and other scripting environments
Using the Detection
Script in ASP applications
At the top of the first page in your application, you should
check for the session variable Session("AppletfileArchive") and call
the detect script if it hasn't been set. Your script should look similar to:
<%
'
' Check browser for java support
'
If Len(Session("AppletfileArchive")) = 0 Then
Response.Redirect "/Appletfile/detect.asp?alt=/your/alt.asp&go=/your/app.asp"
End If
%>
The detect.asp script takes two parameters, alt which should point to the alternate url you want executed if the browser/JVM version is not supported, and the go parameter, which should point back to your application page where you started. If you use relative urls for either of these parameters, keep in mind that they must be relative to the location of the detect.asp script.
Using the
Detection Script in ColdFusion applications
At the top of the first page in your application, you should
check for the session variable session.AppletfileArchive and call the detect
script if it hasn't been set. Your script should look similar to:
<!--- Check browser for java support --->
<CFIF Not IsDefined("session.AppletfileArchive")>
<CFLOCATION URL="/Appletfile/detect.cfm?alt=/your/alt.cfm&go=/your/app.cfm">
</CFIF>
The detect.cfm script takes two parameters, alt which should point to the alternate url you want executed if the browser/JVM version is not supported, and the go parameter, which should point back to your application page where you started. If you use relative urls for either of these parameters, keep in mind that they must be relative to the location of the detect.cfm script.
Support for Perl,
PHP and other scripting environments
If you are using Appletfile in an environment that doesn't
support the detection scripts that come with Appletfile, you will need to
implement your own script. However, this should not be too difficult as most of
the logic runs on the client and by therefore is not dependent on the
server-scripting environment. You should be able to use one of the detection
scripts that comes with Appletfile as a guide for creating your own.
Your detect script will need determine the configuration of the user's browser/JVM using the following steps:
Javascript is detected by sending a page to the browser with a refresh header and a small script that redirects to step 2. If the refresh header executes, that means the script didn't execute so Javascript is either not supported or is disabled.
Support for Java is first test by calling the navigator.javaEnabled() function from Javascript. If this returns true the Detect applet is loaded and used to get more detailed information about the JVM. The Detect applet has the following methods:
Detect.getVendor() - returns the JVM vendor such as Microsoft, Netscape, Apple
or Sun
Detect.getVersion() - returns the JVM version number such as 1.1.4, 1.1.8,
1.3.0, etc.
Detect.checkLiveConnect(Object form) - returns true if JVM supports scripting (aka
LiveConnect).
Once you have the JVM information, you should map it to one of these applet suffixes:
.cab - Microsoft JVM, Internet Explorer 4.0 and higher, Windows only
.jar - Netscape JVM, Netscape Navigator 4.x or Sun JVM 1.3 and higher, Java 2 browser
plug-in
We recommend using some type of session variable to store your suffix to minimize how often the detect script will need to be executed. Consider using cookies if your server-side scripting tool does not support session variables.