<%@ page import = "com.cyscape.browserhawk.*" %>

<!--
   This file is provided under the terms of the BrowserHawk4J license
   agreement.  Copyright (c) 2005-2010 cyScape, Inc. All rights reserved.
-->

<!--
   This example demonstrate how to use BrowserHawk4J to log data to a 
   BrowserHawk4J Reports Web Service servlet (BRWS4J).  To run this
   example you'll need to have BRWS4J installed.  See the docs/brws4j.txt
   file for instructions.  When running this script, make sure to change
   the setBrwsURL() parameter as appropriate for your install.
-->
   

<%
  /* See the docs on the ExtendedOptions class for details on optional 
     settings. */
  ExtendedOptions options = new ExtendedOptions();

  // Set the brws.url
  // CHANGE THIS TO THE APPROPRIATE URL FOR YOUR BRWS4J INSTALL
  options.setBrwsURL("http://localhost:8084/reports/brws");

  // Set the properties to test, and to log
  String extendedPropsToTest = "Plugin_Flash, Height, Width, ColorDepth, CookiesEnabled, JavaScriptEnabled";
  options.addProperties(extendedPropsToTest);

  /* Set the property below to the web path (from the client perspective,
     not physical path) where the JVMDetector.class applet resides.
     Or leave blank if applet is in same directory this script runs from. */
  options.setJVMCodeBase("");

  options.setBodyTag("#FFFFFF");
  options.setPageMessage("Please wait while your browser is checked...");
  options.setPageTitle("Please wait...");
  BrowserInfo bi = BrowserHawk.getBrowserInfo(request);
  options.setRequestType(options.REQUEST_TYPE_AUTO);
  ExtendedBrowserInfo ebi = BrowserHawk.getExtendedBrowserInfo(request, response, options);

  /* If ebi is null we must end the current request here.  The browser will 
     now process the client side tests and call this page back a second time,
     and this time ebi will not be null.  */
  if (ebi == null) return;
%>

<HTML><HEAD><TITLE>BrowserHawk4J Reports Web Service Test</TITLE></HEAD>
<BODY>

<TABLE width=500 BGCOLOR="#CCCCCC" BORDER=1 CELLPADDING=5 CELLSPACING=2>
<TR BGCOLOR="#FFFFFF"><TH WIDTH=175>Property</TH> <TH>Value</TH></TR>
<TR BGCOLOR="#F0F0F0"><TD>Browser</TD> <TD><%= bi.getBrowser() %></TD></TR>
<TR BGCOLOR="#FFFFFF"><TD>Platform</TD> <TD><%= bi.getPlatform() %></TD></TR>
<TR BGCOLOR="#F0F0F0"><TD>Version</TD> <TD><%= bi.getVersion() %></TD></TR>
<TR BGCOLOR="#FFFFFF"><TD>Plugin_Flash</TD> <TD><%= ebi.getPluginFlash() %></TD></TR>
<TR BGCOLOR="#F0F0F0"><TD>Height</TD> <TD><%= ebi.getHeight() %></TD></TR>
<TR BGCOLOR="#FFFFFF"><TD>Width</TD> <TD><%= ebi.getWidth() %></TD></TR>
<TR BGCOLOR="#F0F0F0"><TD>ColorDepth</TD> <TD><%= ebi.getColorDepth() %></TD></TR>
<TR BGCOLOR="#FFFFFF"><TD>CookiesEnabled</TD> <TD><%= ebi.getSessionCookies() %></TD></TR>
<TR BGCOLOR="#F0F0F0"><TD>JavaScriptEnabled</TD> <TD><%= ebi.getJavaScriptEnabled() %></TD></TR>
</TABLE>

<%
  String propsToLog = "Browser, Platform, Version, Plugin_Flash, Height, Width, ColorDepth, CookiesEnabled, JavaScriptEnabled";

  /* Prevent logging stats multiple times for the same visitor's session */
  if (request.getSession().getValue("bhLogged") != Boolean.TRUE) {
    out.println(BrowserHawk.logData(bi, ebi, propsToLog));
    request.getSession().putValue("bhLogged", Boolean.TRUE);
  }
%>
</BODY></HTML>

