<%
  // This sample is provided under the terms of the BrowserHawk End User
  // License Agreement. Copyright (c) 2007-2010 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 builds on rules-basic.jsp to show how a <config> block
  // toward the top can control some behaviors.  It also shows how you
  // can embed CSS in the page to, in this case, suppress the center column.
%>

<%@ 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;
  }

  // * * * * * The <config> block is introduced in rules-config.xml * * * * *
  RuleEngine engine = RuleEngine.getFromFile("rules-config.xml");

  ExtendedOptions options = engine.getExtendedOptions();
  options.setPageTitle("Please wait...");
  options.setPageMessage("Checking your system. Please wait...");
  options.setBodyTag("BGCOLOR=#FFFFFF");

  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" />
  <style type="text/css">  
    .bhawkteststatusheader { display: none; }
    .bhawkteststatus { display: none; }
  </style>
</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);
%>
<%=
  engine.getHtmlResult(info, extBrowser, request)
%>
<%
/*
  LogOptions logOptions = engine.getLogOptions();
  logOptions.setUserID("person");
  out.println(BrowserHawk.logData(info, extBrowser, logOptions, request));
*/
%>

<p>
<b><a href="rules-config.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>
