
/*
 * This applet is used to notify me when a user moves away from the page.
 * It works by opening a connection to a cgi-script on the machine where
 * the page was picked up from when the stop() method is called. All
 * info is passed via the query string.
 *
 * Problems: Netscape (and possibly other browsers) also invokes stop()
 * when when the browser is resized or iconified. This means that the
 * script can be called even though the user has not actually left the
 * page.
 */

import java.applet.Applet;
import java.net.URL;


public class NotifyPageExit extends Applet
{
    private String script;


    public void start()
    {
	script = getParameter("script");
    }


    public void stop()
    {
	if (script == null)
	    return;

	try
	{
	    URL home = new URL(getCodeBase(), script);
	    home.openConnection().getInputStream().close();
	}
	catch (Exception e)
	{
	    return;
	}
    }
}


