Example #1: Overriding the LU name based on the client's IP address

Administrators may want to avoid specifying LU names directly in session definitions. This example shows a simple way of using the IP address of the client to look up an LU name listed in a text file and use it as an override value in a session.

This example is written using JSP. The Deployment Wizard was used to create an HTML file that contains two sessions named 3270 Display and 5250 Display. Note that in Z and I Emulator for Web 7 and later, some of the HTML is generated using JavaScript, and HTML parameters are specified within a JavaScript array or using JavaScript document.write statements. Also, the format of the HTML varies according to the client .

This example uses a cached Java page to start from with the needed changes for HTML overrides in bold. When the Deployment Wizard is used to generate a cached Java2 page it generates the following files: A Macintosh client makes use of the Example_J2.html page.
A file (c:\luname.table) is read that contains IP address/LU name pairs. The IP address of the client is used to look up the proper LU name, which is overridden in the "3270 Display" session. See the comments in the example for more detail. The lines added to the Deployment Wizard output are displayed in bold.
<!doctype html public "-//W3C//DTD HTML 3.2 Final//EN">
//  Read the luname.table file into a properties variable.
//  The luname.table file contains lines in the following format:
//    ipaddress=luname
Properties lunames = new Properties();
lunames.load(new FileInputStream("c:\\luname.table"));
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- TITLE Begin -->
<TITLE>Example1 page title</TITLE>
<!-- TITLE End -->
<!-- SUMMARY Begin -->
Configuration Model
	What configuration model would you like to use?
	-HTML-based model
Host Sessions 
	-3270 Display
	-5250 Display
Additional Options
	-Cached = Cached client
	-Java Type = java2
Disable Functions
Preload Options
	-5250 Sessions = True
	-Change Session Properties = True
	-3270 Sessions = True
Web Start Options
	Basic Options
	-Debug = False
	-Height (in pixels) = 250
	-Width  (in pixels) = 550
	Upgrade Options
	-Percent of users who can upgrade by default = 100
	-Prompt user (user decides foreground or background)
Advanced Options
	HTML parameters
	Code base
	- /zieweb/
	HTML templates
	Problem determination
	-Debug = False
	User updates
	-Persist user updates? = True
	-Standard Z and I Emulator for Web Client
	Server connection
	-Locale = Use the system Locale
	Maximum sessions
	- 26
<!-- SUMMARY End -->

function writeAppletParameters()
   return "";

<SCRIPT LANGUAGE="JavaScript" SRC="/zieweb/ziewebversion.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/zieweb/CommonJars.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/zieweb/CommonParms.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/zieweb/CommonJ2Parms.js"></SCRIPT>
var db = parent.location;
var zie_Locale = '';
var zie_AppName ='';
var zie_AppHgt = '340';
var zie_AppWid = '550';
var zie_CodeBase = '/zieweb/';
var zie_Archs = 'habasen.jar,ziebasen.jar,zieimg.jar,hacp.jar,hafntib.jar,hafntap.jar,

var zie_URL = new String(window.location);
var zie_DebugOn = false;
var hZie_AppletParams = new Array;
hZie_AppletParams[1] = '<PARAM NAME="ShowDocument"      VALUE="_parent">';
hZie_AppletParams[3] = '<PARAM NAME="ParameterFile"     VALUE="ZIEWebData\\Example1\\params.txt">';
hZie_AppletParams[4] = '<PARAM NAME="JavaScriptAPI"     VALUE="false">';
hZie_AppletParams[5] = '<PARAM NAME="BookmarkPage"      VALUE="Example1.html">';

// The next 2 lines are required in order to override session properties.
//  The first line turns on the processing for this function and does not 
//  need to be modified.  The second line identifies the sessions that you
//  want to change.  In this example, there are 2 sessions identified 
//  named: "3270 Display" and "5250 Display".
hZie_AppletParams[6]='<PARAM NAME="EnableHTMLOverrides" VALUE="true">';
hZie_AppletParams[7]='<PARAM NAME="TargetedSessionList" VALUE="3270 Display,5250 Display">';
// The following line changes the LUName session parameter for the session named
//  "3270 Display".  In this example, the LUName is being set to the value   
//  contained in the c:\luname.table for the IP address of the client.
//  When you are initially testing your changes, you may want to use a constant
//  value to verify that the syntax is correct before you insert your 
//  calculations.
hZIe_AppletParams[8]='<PARAM NAME="Luname" VALUE="3270 

//hZie_AppletParams[x] = '<PARAM NAME="DebugCode"              VALUE="65535">';

var pg = buildJ2Page(db);
pg += writeAppletParameters();
pg += '</APPLET>';
if(zie_DebugOn) alert('J2 page complete, result = \n' + pg);