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

// This sample is provided under the terms of the BrowserHawk End User License
// Agreement.  Copyright (c) 2003-2010 cyScape, Inc.  All rights reserved.

// This example demonstrates how to use BrowserHawk to check for disabled
// cookies.  Note that with IE 5 and higher it is possible to have cookies
// disabled differently for "session" cookies (which expire immediately upon
// closing your browser) vs. "persistent" cookies (which expire at a date/time
// set at the time the cookie is created).  This example also shows you to
// detect the difference between session vs. persistent cookie settings.

// Disabled cookies are checked using "extended" property checks and the
// factory method BrowserHawk.getExtendedBrowserInfo().  To fully understand
// extended property checks we recommend reading the source to the
// popular.jsp sample.

// To avoid an exception, we first check that the system executing this
// example has a Professional or Enterprise Edition license as required
// for this test.
// Note: This is NOT needed in your pages, only for this generic sample.
  if (BrowserHawk.getVersion().indexOf("Pro") == -1 &&
      BrowserHawk.getVersion().indexOf("Ent") == -1) {
    out.println("Professional or 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;
  }

// First we create an instance of the ExtendedOptions class so we can tell
// BrowserHawk which tests we want performed (in this case to test for
// disabled cookies).

	ExtendedOptions options = new ExtendedOptions();

// Now we tell BrowserHawk we want it to test for both disabled session and
// persistent cookies.
	
	options.addProperties("SessionCookies, PersistentCookies");

// Tell BrowserHawk to execute the test now.  Note there are many useful
// optional settings that can be used with getExtendedBrowserInfo() through
// the ExtendedOptions class passed in.  This is demonstrated in the
// popular.jsp sample - see that sample for more information.
  
	ExtendedBrowserInfo extBrowser = BrowserHawk.getExtendedBrowserInfo(request, response, options);

// A null return value indicates JavaScript has been sent and
// we should immediately return

  if (extBrowser == null) return;

// Now that we have the results let's display them.

%>

<html>
	<head>
		<title>BrowserHawk Sample - Detect disabled cookies (Java)</title>
	</head>
	<body><font face="arial">
	<blockquote>
		The status of your cookies is as follows:
		<p>
		</p>
		Session cookies:
	<%
		if (extBrowser.getSessionCookies())
			out.println("ENABLED");
		else
			out.println("DISABLED");
	%>
		<p></p>
		Persistent cookies:
	<%
		if (extBrowser.getPersistentCookies())
			out.println("ENABLED");
		else
			out.println("DISABLED");
	%>

<HR>

<P>
<b><a href="cookies.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>
</blockquote>
</body>
</html>
