Preventing Users from Disconnecting or Navigating Away from Reflection for the Web Sessions

  • 7022457
  • 21-Oct-2004
  • 25-Mar-2018

Environment

Reflection for the Web 2014 (All Editions)
Reflection for the Web 2011 (All Editions)
Reflection for the Web 2008 (All Editions)

Situation

This note describes procedures to avoid having users unintentionally browse away from their Reflection for the Web Sessions, and to prevent users from exiting Reflection for the Web while connected to a host. This can prevent ghost sessions on the host.

Resolution

Alerting Users to Disconnect Before Exiting or Navigating Away

You can configure Reflection for the Web to notify users to disconnect a host connection before they exit, thereby preventing ghost sessions on the host. The method you use depends on the kind of session you are running:

  • For Out-of-Browser Sessions – you can add an applet parameter to the session configuration that will display an alert message if the user attempts to exit the session while still connected.
  • For Embedded Sessions – you can run a script that notifies the user to disconnect from the host before closing the browser window or navigating away.

For Out-of-Browser Sessions

When you configure a session to use the following applet parameter, users are required to disconnect from the host before they can close the browser. Follow these steps to configure your session.

  1. Open the Administrative WebStation Session Manager tool.
  2. Select a session to configure by clicking it.
  3. In the Advanced settings section, click the Applet Parameters button.
  4. In the Add parameters section, select onExitJavaClass from the Parameter drop-down list.
  5. In the Value field, enter com.wrq.eNetwork.ECL.modules.PreventSessionClose
  6. Click Add.
  7. On the Applet Parameters page, click Continue.
  8. Click Save Settings.

Now when a user tries to close the browser, if the session is still connected, a message box will open saying, "You must disconnect from the host before exiting Reflection." If the session is already disconnected, the browser will close without displaying a message.

Modifying the Message Title and Text

The text and title of this message can be modified by following the steps below.

  1. Open the Administrative WebStation and click Session Manager.
  2. Click the session you want to configure.
  3. Click Applet Parameters.
  4. In the Parameter field of the Custom parameters section, enter preventSessionCloseLabel.

This parameter enables you to customize the error message.

  1. In the Value field of the Custom parameters section, enter your customized message in the Value field, and then click Add.
  2. Repeat steps 4 and 5 for the parameter preventSessionCloseTitle.

This parameter enables you to customize the title of the error message.

  1. Click Continue, and then click Save Settings.

For Embedded Sessions

If you are running an embedded session, you can add a script to a JSP template that notifies users to disconnect from the host if they are still connected when exiting the browser or when navigating to another page. The script may not be able to enforce this action, however, and there may be differences in behavior between different browsers or browser versions.

The following example shows a JSP template for an embedded session that displays an alert message if the session is still connected to the host when the user attempts to close the browser or navigate away.

<%@ taglib  uri="/WEB-INF/rweb.tld" prefix="rweb" %>
<html>
<head>
<script>
    // Register the confirmExit function as an
    // onbeforeunload event handler.
    window.onbeforeunload = confirmExit;
    
    var jsapi;
    
    /*
     * This function is invoked automatically by the
     * Reflection session after session initialization is
     * complete. It receives a reference to the JavaScript
     * API.
     */
    function jsapiInitialized( api )
    {
        jsapi = api;
    }
    
    /*
     * Invoked from the onbeforeunload handler. If
     * the session is still connected, returns a message
     * to the browser that asks the user if it's okay to
     * leave the page.
     */
    function confirmExit() 
    {
        if ( jsapi != null && jsapi.isConnected() )
        {
            return "The session is still connected. Please " +
                "disconnect before closing the page or navigating away.";
        }
    }
</script>
   <title>Prevent Browse Away Example</title>
</head>
<body>
    <!-- 
        The "preloadJSAPI" parameter will preload the Reflection
        JavaScript API and send a notification message to the 
        jsapiInitialized function.
    -->
   <rweb:applet userequest="true">
        <rweb:param name="preloadJSAPI" value="true"/>
    </rweb:applet>
</body>
</html>

Additional Information

For technical resources for your product, see:

Reflection for the Web 2014: https://support.microfocus.com/product/?prod=RWEB2014

Reflection for the Web 2011: https://support.microfocus.com/product/?prod=RWEB11

Reflection for the Web 2008: https://support.microfocus.com/product/?prod=RWEB08

Legacy KB ID

This document was originally published as Attachmate Technical Note 1833.