Technical Notes |
|
This technical note describes how to programmatically control Reflection for the Web sessions embedded in browser windows. The note outlines three different methods using JavaScript and the Reflection for the Web application programming interface (API) to control Reflection.
In addition, custom Jscript, VBScript, Java applets, and Java applications can use the Reflection for the Web (API) to control Reflection applets. For more information about the Reflection for the Web API, see the "Scripting with the Reflection API" section in the Administrative WebStation.
Note: This note covers Reflection sessions embedded in a browser window. For information about controlling framed (out-of-browser) sessions, see Technical Note Number 1776.
This note outlines three methods for programmatically controlling Reflection for the Web embedded sessions using JavaScript to access the Reflection for the Web API. Attachmate Technical Support recommends using Method 1 (below), which uses protected, dynamic sessions rather than static or unprotected sessions.
The following terms are used throughout this document.
Dynamic sessions are created when a session is requested. These sessions are not associated with a physical HTML file on the web server. This is the default session type in Reflection for the Web. All dynamic sessions are protected sessions.
Static sessions are associated with an HTML file located on the web server. Static sessions can be either protected or unprotected sessions.
Protected sessions are only indirectly accessible from a web server. The request for a protected session goes through the Reflection for the Web authentication and authorization process before it is served.
Unprotected sessions are accessed by direct URL addresses and do not take advantage of the Reflection for the Web authentication and authorization process.
The following is a summary of the three available methods and their possible advantages and disadvantages. Specific configuration details are provided in subsequent sections.
We recommend using this method. Protected, dynamic sessions take full advantage of Reflection for the Web's features, including Reflection Server management and access control. Using this method, you can use an IFRAME tag to incorporate JavaScript into your dynamic Reflection sessions.
Possible disadvantage:
Both the session name and the HTML file name appear in the Reflection links list. For example, <Mainframe name>.html.
View details: Method 1: Programmatically Controlling Protected Dynamic Sessions with an IFRAME Tag
Use this method if your Reflection sessions are protected, static sessions.
Possible disadvantages:
View details: Method 2: Programmatically Controlling Protected Static Sessions
Use this method if your Reflection sessions are unprotected, static sessions.
Possible disadvantages:
View details: Method 3: Programmatically Controlling Unprotected Static Sessions
The Reflection for the Web server generates HTML applet tags for all sessions using the Launcher (com.wrq.rweb.Launcher) applet, and the Launcher applet launches child Reflection emulation applets. With this launching methodology, the Launcher getAPI() method is needed to reference specific Reflection emulation child applet sessions. The syntax for the getAPI() Launcher method is getAPI("JSAPI", "<session_name>").
var appletTarget = document.applets[0].getAPI("JSAPI","VT");The first parameter is the API type you want to use, and the only API available at this time is the JavaScript API named "JSAPI." The second parameter assigns the getAPI() to the Reflection session you want to control. Generally, the session_name is the launcher.sessions value. Below is a list of launcher.sessions values for all of the Reflection for the Web emulations. (Alternatively, you can view the source of Reflection for the Web applet web pages and look for the "launcher.sessions" parameter name.)
HP |
|
IBM3270 |
|
IBM3287 |
for IBM 3270 printer sessions |
IBM5250 |
|
IBM3812 |
for IBM 5250 printer sessions |
IBM5250Xfer |
for AS/400 data transfer sessions |
VT |
|
However, when controlling protected dynamic sessions with an IFRAME tag, the portal=true argument is typically used within the IFRAME tag to avoid refreshing the entire HTML page with a new Launcher applet session. This allows you to embed a Reflection session within existing HTML content. When using the portal=true argument, the literal session name as it appears in the links list is used for the getAPI session_name value.
You can incorporate JavaScript into your dynamic sessions by using an IFRAME tag, which creates an inline frame containing the Reflection session. Follow the steps below to control protected, dynamic Reflection for the Web sessions.
https://<your server>:<HTTPS port number>/<management server context>/AdminStart.htmlFor example, if the server is www.ourcompany.com and the management server context is rweb (the default), the URL is
https://www.ourcompany.com:843/rweb/AdminStart.htmlAlternately, you may be able to access the links list page by clicking Start > Programs > Reflection for the Web > Administrative WebStation.
Note: If the name of the terminal session contains any spaces or special characters, right-click the session's link and select “Copy URL to clipboard.” The link name is embedded in the URL listed in the Address field. It contains the HTML indicators that denote spaces or special characters. Paste the URL into a text editor and make a note of the link name, including the special characters.
For example, a link titled "Sales Data" is represented by red text in the following URL:
https://www.mycompany.com:843/rweb/RWebSession.do?link=Sales*u0020Data&rwebgroup=admin
<!-- -------------------------------------------------------- --><HTML><HEAD><TITLE>Example: How to programmatically control Rweb with an IFRAME tag.</TITLE> <SCRIPT Language="JavaScript"> <!-- var appletTarget = null; /* This function displays an about dialog box. */ function showAbout() { appletTarget = document.frames("rwebiframe") .document.applets[0].getAPI("JSAPI","[literal session name]"); appletTarget.showDialog( "aboutBoxDialog" ); } //--> </SCRIPT></HEAD><BODY> <H3>Example: How to programmatically control Rweb with an IFRAME tag. </H3> <P> <IFRAME NAME ="rwebiframe" src="RWebSession.do?link=[URL session name]&portal=true&appletOnly=true" frameborder=0 scrolling=no height=420 width=620> </IFRAME> <FORM> <INPUT TYPE = "BUTTON" VALUE = "About Reflection for the Web" onClick = "showAbout();"> </FORM></BODY></HTML><!-- -------------------------------------------------------- --> |
C:\Program Files\ReflectionServer\ReflectionData\deployNote the following:
C:\Program Files\ReflectionServer\jakarta-tomcat\webapps\rweb\ Follow the steps below to create a protected static Reflection for the Web HTML page and add any desired scripting code to the page.
https://<your server>:<HTTPS port number>/<management server context>/AdminStart.htmlFor example, if the server is www.ourcompany.com and the management server context is rweb (the default), the URL is
https://www.ourcompany.com:843/rweb/AdminStart.htmlAlternately, you may be able to access the links list page by clicking Start > Programs > Reflection for the Web > Administrative WebStation.
Note: In the example below, change the session name, the URL to the management server context, and the configuration zip file name for your environment.
<!-- -------------------------------------------------------- --><HTML><HEAD><TITLE> Example: How to Programmatically Control a Protected Static RWeb Session.</TITLE> <SCRIPT Language="JavaScript"> /* This function displays an about dialog box. */ function showAbout() { var appletTarget = document.applets[0].getAPI("JSAPI","VT"); appletTarget.showDialog( "aboutBoxDialog" ); } //--> </SCRIPT></HEAD><H3>Reflection for the Web</H3><applet MAYSCRIPT name="[session name]" code="com.wrq.rweb.Launcher.class" codeBase="./ex/" width="600" height="400" archive="https://[your server]:[HTTPS port number]/[management server context]/ex/Launcher.jar"><param name="cabbase" value="Launcher.cab"><param name="configuration" value="[file name].zip"><param name="menuType" value="admin"><param name="showStatusLine" value="true"><param name="shortcutMenu" value="true"><param name="launcher.sessions" value="VT"></applet><BODY> <H3>Example: How to Programmatically Control a Protected Static RWeb Session. </H3> <P> <FORM> <INPUT TYPE = "BUTTON" VALUE = "About Reflection for the Web" onClick = "showAbout();"> </FORM></BODY></HTML><!-- -------------------------------------------------------- --> |
<param name="preloadJSAPI" value="true">C:\Program Files\ReflectionServer\ReflectionData\deploy\<my page>.htmlNote: If the script code is to reside in an external JavaScript (*.js) file, the file must reside in web-addressable space outside of the deploy directory. In a default Windows installation of Reflection for the Web, this includes the following directory and any subdirectories, except for the WEB-INF directory and any subdirectories:
C:\Program Files\ReflectionServer\jakarta-tomcat\webapps\rweb\ <param name="configuration" value="confXXXXX.zip">Follow the steps below to create an unprotected static Reflection for the Web HTML page and add any desired scripting code to the page.
Note: This method is not an option if you are using an evaluation version of Reflection for the Web with secure sessions configured to use the Reflection for the Web security proxy. An evaluation version, configured in this manner, will display an error stating that the evaluation copy expired on January 1, 1970.
https://<your server>:<HTTPS port number>/<management server context>/AdminStart.htmlFor example, if the server is www.ourcompany.com and the management server context is rweb (the default), the URL is
https://www.ourcompany.com:843/rweb/AdminStart.htmlAlternately, you may be able to access the links list page by clicking Start > Programs > Reflection for the Web > Administrative WebStation.
Note: In the example below, change the session name, the URL to the management server context and the configuration zip file name for your environment. Also, as in the below code, change the codeBase applet tag parameter from codeBase="./ex/" to a literal URL or a correct relative path to the Reflection for the Web \ex directory. For example, default Windows installations require the codeBase="./ex/" parameter to change to codeBase="../ex/".
<!-- -------------------------------------------------------- --><HTML><HEAD><TITLE>Example: How to Programmatically Control an Unprotected Static RWeb Session.</TITLE> <SCRIPT Language="JavaScript"> /* This function displays an about dialog box. */ function showAbout() { var appletTarget = document.applets[0].getAPI("JSAPI","VT"); appletTarget.showDialog( "aboutBoxDialog" ); } //--> </SCRIPT></HEAD><H3>Reflection for the Web</H3><applet MAYSCRIPT name="[session name]" code="com.wrq.rweb.Launcher.class" codeBase="../ex/" width="600" height="400" archive="https://[your server]:[HTTPS port number]/[management server context]/ex/Launcher.jar"><param name="cabbase" value="Launcher.cab"><param name="configuration" value="[file name].zip"><param name="menuType" value="admin"><param name="showStatusLine" value="true"><param name="shortcutMenu" value="true"><param name="launcher.sessions" value="VT"></applet><BODY> <H3>Example: How to Programmatically Control an Unprotected Static RWeb Session. </H3> <P> <FORM> <INPUT TYPE = "BUTTON" VALUE = "About Reflection for the Web" onClick = "showAbout();"> </FORM></BODY></HTML><!-- -------------------------------------------------------- --> |
<param name="preloadJSAPI" value="true">C:\Program Files\ReflectionServer\jakarta-tomcat\webapps\rweb\ session\<my page>.htmlC:\Program Files\ReflectionServer\ReflectionData\deploy\dyncfgsand
C:\Program Files\ReflectionServer\jakarta-tomcat\webapps\rweb\session\If you're unable to determine which confXXXXX.zip file belongs to the session you saved, view the HTML applet source as described in step 2 above and find the confXXXXX.zip value in the below applet parameter.
<param name="configuration" value="confXXXXX.zip">https://<your server>/<Reflection for the Web application context>/session/<Reflection for the Web session name>.htmlNote: With IIS, you may need to specify the IIS port number by using the following format:
https://<your server>:<IIS port number>/<Reflection for the Web application context>/session/<Reflection for the Web session name>.htmlSince static, unprotected sessions don't use the Reflection for the Web management server to manage sessions, the Security Proxy client authorization feature (which uses tokens) is not supported, so client authorization must be disabled. After client authorization is disabled, a unique proxy and port must be defined for each host you access. (For details on enabling and configuring the Security Proxy Server, use the Search feature in the Administrative WebStation.) Once the Security Proxy Server is enabled, follow the steps below to turn off client authorization. (Note that beginning in Reflection for the Web 2008, the Security Proxy Server is not included in the Standard Edition.)