<%
  // This sample is provided under the terms of the BrowserHawk End User
  // License Agreement. Copyright (c) 2007-2011 cyScape, Inc. All rights reserved.
  //
  // This example demonstrates Rules Enforcement Technology (RET), where
  // an XML file describes tests to perform and what actions to take with
  // different results.
  //
  // This example tests several properties and generates an HTML summary
  // table report.
%>

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

<%
  // To avoid an exception, we first check that the system executing this
  // example has an Enterprise Edition license as required for this test.
  // Note: This is NOT needed in your pages, only for this sample.
  boolean isEnterprise = (BrowserHawk.getVersion().indexOf("Ent") != -1);
  if (!isEnterprise) {
    out.println("Enterprise License Required.  ");
    out.println("You are using " + BrowserHawk.getVersion() + ".  ");
    out.println("See <a href='http://www.cyscape.com/order/'>http://www.cyscape.com/order/</a> for upgrade information.");
    return;
  }

  // Create a RuleEngine instance feeding it some XML data.
  // The rules-basic.xml file can be specified with an absolute path
  // or as a relative path to your CLASSPATH environment.  Here the
  // XML file can be found under WEB-INF/classes.
  // See the RET tutorial for an explanation of this file format.
  RuleEngine engine = RuleEngine.getFromFile("rules-basic.xml");

  // Configure the properties to test so that they match the properties
  // needed by the XML test file.  This way the XML can change and this
  // code doesn't have to.
  ExtendedOptions options = engine.getExtendedOptions();

  // Configure a few test options
  options.setPageTitle("Please wait...");
  options.setPageMessage("Checking your system. Please wait...");
  options.setBodyTag("BGCOLOR=#FFFFFF");

  // Start the test
  ExtendedBrowserInfo extBrowser =
    BrowserHawk.getExtendedBrowserInfo(request, response, options);

  // If the return value 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 the return value will not be null.
  if (extBrowser == null) return;
%>

<html>
<head>
	<title>BrowserHawk Sample - Performing a Rules Test (Java)</title>
  <link href="rules.css" rel="stylesheet" type="text/css" />
</head>
<body><font face="arial">
<blockquote>
<h2>Performing a Rules Test (Java)</h2>

<font size=3>
<p>
This sample demonstrates basic use of Rules Enforcement Technology (RET).
</p>
<p>
The table is dynamically built, but the test criteria are for demo
purposes only.  <i>There's no need to take serious any failure
displays in the results!</i>
</p>
<p>

<%
  BrowserInfo info = BrowserHawk.getBrowserInfo(request);
%>
<%=
  // Execute the tests, taking the actions dictated by the XML
  engine.getHtmlResult(info, extBrowser, request)
%>
<%
/*
  // You could log the data as well, but here it's commented out
  LogOptions logOptions = engine.getLogOptions();
  logOptions.setUserID("person");
  out.println(BrowserHawk.logData(info, extBrowser, logOptions, request));
*/
%>

<p>
<b><a href="rules-basic.jsp">Retry this test</a></b><P>
<b><a href="index.html">Return to list of other JSP samples</a></b><P>
<b><a href="http://www.cyscape.com/order/">BrowserHawk Pricing and Ordering</a></b><P>
<b><a href="http://www.cyscape.com/">cyScape home page</a></b><P>
</font>
</font>
</blockquote>
</body>
</html>
