docmain.css" /> HTML Samples - Reflection for the Web Reference Guide highlight.css">

4.0 HTML Samples

4.1 HTML Code Samples

In Reflection for the Web, lists of session links are provided in a login applet. After a user logs in, a list of links to available sessions opens. If you want to create a custom web page for your users instead of using the provided links list, log in as a user (not as an administrator) to whom sessions are assigned, and then right-click a link to copy the URL to the clipboard. You can then paste the URL into your customized web page.

4.1.1 About HTML code samples

In Reflection for the Web, you have several options for emulator session files. The Manage Sessions interface provides an easy way to create sessions with most of the basic functionality you need. Session files defined here are dynamically generated upon user request and provide full security and access control functionality.

You can also save a customizable form of session files in the deploy folder. Files in this folder cannot be edited in Manage Sessions, but they can be assigned to users in the Assign Users & Groups panel. These session files provide the same security and access control as sessions created using Manage Sessions.

To customize Reflection for the Web session files:

  1. Use a text editor or to create the basic HTML and applet tag for the session. If you use the , copy the HTML from the More Settings page and paste it into a text file.

  2. Add custom HTML, JavaScript, or Reflection API code to the file.

  3. Give the file a name with an .html extension and save it to MSSData/deploy.

  4. Place any image files or other files called by the session html file in the session folder.

You can also save the session HTML to the session folder. However, files in this folder cannot be assigned to users and do not benefit from Management and Security Server's access control features.

The samples in this section provide examples of sessions that can be stored in the deploy folder. Modifications using HTML and JavaScript extend the functionality provided by the basic session files created using Manage Sessions.

NOTE:Micro Focus permits you to edit, manipulate, and change graphics, text, HTML code, JavaScript code, Java code, and other code in Reflection for the Web samples. The sample code and graphics are for use solely with deploying your internal Reflection web pages and for no other purpose. Micro Focus has no warranty, obligation, or liability for the contents of the samples.

Troubleshooting Tip

The sample pages are available so that you can view the page and copy the sample code to a new HTML file. If the sample code is not formatted correctly after you paste it into your text editor, try reselecting the sample code, making sure that you extend your selection to the blank line after the end of the sample.

Some browsers, such as Internet Explorer, do not copy all of the code formatting unless an ending paragraph mark is also selected. You can ensure that the paragraph mark is included in the selection by including the blank line after the last line of code.

4.1.2 Available HTML code samples

Choose from a number of detailed examples of HTML code samples for running terminal sessions and associated tasks.

More advanced functionality is available using the Reflection API with JavaScript, VBScript, or Java. See the API section for more information.

Running a terminal session with printer emulation

You can easily run two sessions from a single page. The best way to set up this kind of multiple emulation session is to follow these steps:

  1. Create the first session using the session management panel in the Administrative Console.

  2. On Configure a Web-Based Reflection Session, click More. Copy the session HTML from the View HTML box.

  3. Paste the HTML into a text editor.

  4. Return to session management and create the second session.

  5. In the View HTML box, select just the applet tag and its parameters. Copy this text. (You can also copy the entire text to the clipboard, paste it into a second text file, and then copy just the applet text from that file.)

  6. Paste the second applet into the text file containing the first applet and save the results in the deploy folder as [session_name.html].

Sample code

This sample HTML code demonstrates how to start a standard IBM 3270 session with the IBM 3270 printer running in the background. The applet launches the terminal session in a separate window, and the code is designed for Internet Explorer and Firefox browsers.

The first applet in the sample loads a 3270 host session named myHost on port 23, in the browser window. The second applet opens a 3270 printer session on a device named myDevice on port 23, running in its own window. The two sessions are associated using the tnAssociation parameter.

<html>
<head>
<title>IBM 3270 with Printer Session</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="charset" content="iso-8859-1">
</head>
<body>
<h3>3270</h3>
<applet mayscript name="IBM3270Frame" 
	   code="com.wrq.rweb.Launcher.class"
   codeBase="./ex/" 
	   width="600" 
   height="400" 
   	archive="Launcher.jar">
<param name="securityEnabled" value="false">
<param name="encryptStream" value="false">
<param name="hostURL" value="tn3270e://myHost:23">
<param name="deviceName" value="myDevice">
<param name="tnAssociation" value="assocString">
<param name="autoDetect" value="true">
<param name="launcher.sessions" value="IBM3270">
</applet>
<applet mayscript name="IBM3287Device" 
   	code="com.wrq.rweb.Launcher.class"
   codeBase="./ex/" 
	   width="0" 
   height="0" 
	   archive="Launcher.jar">
<param name="frame" value="true">
<param name="title" value="Reflection for the Web - IBM3287Device">
<param name="securityEnabled" value="false">
<param name="encryptStream" value="false">
<param name="hostURL" value="tn3270e://myHost:23">
<param name="promptForDeviceName" value="false">
<param name="tnAssociation" value="assocString">
<param name="tn3270eConnectType" value="0">
<param name="autoDetect" value="true">
<param name="launcher.sessions" value="IBM3287">
</applet>
</body>
</html>

Providing access to menu commands with images and the API

This sample code demonstrates how to use images with the Reflection application programming interface (API) to provide access to specific menu functions for an embedded session. This is particularly useful when you want to restrict your user's access to certain functionality. The applet launches the terminal session embedded in the browser window (the shortcut menu is not enabled), and the code is designed for Internet Explorer and Firefox browsers.

To start a terminal session using this sample

  1. Copy the JavaScript code and applet tag below to an HTML file. (If there are two or more applets on the page, confirm that each applet in the file has a different name.)

  2. In the hostURL parameter, replace myHost with the name or URL of the host to which you want to connect. If you choose not to connect automatically, delete the hostURL and autoconnect parameters.

  3. Save the file in the deploy folder.

  4. Copy the images used by this page (Screen.gif, Palette.gif, and Key.gif) to the session folder. (Note that this is a different folder than the one in which the HTML file is stored.) The .gif files used in this sample are stored in the following folder of the Administrative Console: <WebStation installation folder>\admin\en\html\advanced\sample_images\

    In addition to the images used in this sample, there are other images in the sample_images folder that can be used to provide user access to menu functions.

Sample code

Dynamically allocating ports and assigning device names

For Internet Explorer and Firefox browsers

These two samples demonstrate how to dynamically:

  • Specify a port number in a terminal session. The applet launches the session in a separate window.

  • Specify a device name or pool in an IBM 3270 Printer session. For example, you could modify this code to assign a device name to specific users based on the user name. The applet launches the terminal session in a separate window. Devices are used in IBM emulation sessions only.

To start a terminal session using this sample page

  1. Copy the sample JavaScript code below to an HTML file.

  2. In the first block of JavaScript code, add custom code to determine the port number or device name you want to use. The inserted code should return the string (in quotes) of the port or device name to use.

  3. In the hostURL parameter, replace myHost with the name or URL of the host to which you want to connect.

  4. To specify a port number: In the launcher.sessions parameter, replace session type with the appropriate session type indicator:

    Session type

    Indicator

    HP

    HP

    IBM 3270

    IBM 3270

    IBM 3270 printer

    IBM3287

    IBM 5250

    IBM 5250

    IBM 5250 printer

    IBM 3812

    IBM AS/400 data transfer

    IBM 5250Xfer

    VT

    VT

    To specify a device name: skip to step 5.

  5. Save the file in the deploy folder.

Sample code to allocate port numbers
<script language="JavaScript">
<!--
// Add JavaScript code here to determine the port number.
function getPort()
{
   return "23";
}
document.writeln( '<applet mayscript name="Dynamic_Port"' );
document.writeln( ' code="com.wrq.rweb.Launcher.class"' );
document.writeln( ' codebase="./ex/"' );
document.writeln( ' width="0" height="0"' );
document.writeln( ' archive="Launcher.jar">' );
// Get the value for the port and insert it into the applet parameter.
port = getPort();
document.writeln( '<param name="hostURL" value="tn3270://MyHost:' + port + '">' );
document.writeln( '<param name="frame" value="true">' );
document.writeln( '<param name="menuType" value="advanced">' );
document.writeln( '<param name="autoDetect" value="true">');
document.writeln( '<param name="launcher.sessions" value="session type">');
document.writeln( '</applet>' );

// End of comment -->
</script>
Sample code to assign device names
<script language="JavaScript">
<!-- Comment for non-JavaScript browsers.  
// Add JavaScript code here to determine the device name.
    function getDeviceName()
    {
        return "myDevicePool";
    }

document.writeln( '<applet mayscript name="IBM3287Device"' );
document.writeln( ' code="com.wrq.rweb.Launcher.class"' );
document.writeln( ' codebase="./ex/"' );
document.writeln( ' width="0" height="0"' );
document.writeln( ' archive="Launcher.jar">' );
// Get the value for deviceName and put it into the applet parameter.
device = getDeviceName();
document.writeln( '<param name="deviceName" value="' + device + '">' );
// In the hostURL parameter, replace myHost with a valid host name or URL.
document.writeln( '<param name="hostURL" value="myHost">' );
document.writeln( '<param name="autoconnect" value="true">' );
document.writeln( '<param name="frame" value="true">' );
document.writeln( '<param name="menuType" value="advanced">' );
document.writeln( '<param name="autoDetect" value="true">');
document.writeln( '<param name="launcher.sessions" value="IBM3287">');
document.writeln( '</applet>' );
    
// End of comment -->
</script>

Disabling browser navigation

This sample JavaScript code demonstrates how to start a standard session in a new window with the browser navigation controls disabled in either Internet Explorer or Firefox browsers.

To start a terminal session using this sample

  1. Copy the sample JavaScript code below to an HTML file

  2. In the hostURL parameter, replace myHost with the name or URL of the host to which you want to connect. If you choose not to connect automatically, delete the hostURL and autoconnect parameters.

  3. Save the file in the deploy folder.

Sample code
<script language="JavaScript">
<!-- Comment for non-JavaScript browsers.

targetwin = window.open( "", "IBM3270Applet", "status=yes, width=650, height=550" );
targetdoc = targetwin.document;

// Use the "with (object)" statement to simplify the following lines.
with ( targetdoc ) {
    writeln( '<html>' );
    writeln( '<body>' );
    writeln( '' );
    writeln( '<h1>Reflection for IBM 3270</h1>' );
    writeln( '<applet mayscript name="IBM3270"' );
    writeln( '        code="com.wrq.rweb.Launcher.class"' );
    writeln( '        codebase="./ex/"' );
    writeln( '        width="600" height="400"' );
    writeln( '        archive="Launcher.jar">' );
    writeln( '    <param name="hostURL" value="tn3270://myHost:23">' );
    writeln( '    <param name="autoconnect" value="true">' );
    writeln( '    <param name="shortcutMenu" value="true">' );
    writeln( '    <param name="frame" value="false">' );
    writeln( '    <param name="launcher.sessions" value="IBM3270">' );
    writeln( '</applet>' );
    writeln( '' );
    writeln( '<form>' );
    writeln( '    <input type="button"  ');
    writeln( '           name="Close" ' );
    writeln( '           value="Close Window" ' );
    writeln( '           onClick="window.close()"> ');
    writeln( '</form>' );
    writeln( '' );
    writeln( '</body>' );
    writeln( '</html>' );
    close();     
}

// End of comment -->
</script>