Note: You may not be licensed to run all RTView data sources.
This example requires that you have a working knowledge of RTView. If you would like to work through a basic example, please complete the “Quick Start Tutorial” before continuing. This exercise also assumes that you have a web server running and that you have a standard working knowledge of that server. In addition, you must be familiar with deploying Java Sever Pages on your web server.
§ To understand how to reference a JSP file on an active server instead of directly referencing an XML file.
Using Java Server Pages is a convenient way to provide data to RTView. Instead of directly referencing an XML file, you can reference a JSP file on an active server. Via the JSP file, the server returns formatted XML data to each RTView client that requests it. The advantage of retrieving XML data from Java Server Pages is that an intermediary XML file is not necessary and all client server communication is managed automatically by the HTTP server. Using Java Server Pages also provides a way to limit the data transferred to only what is requested by the individual clients.
The demos\dstutorial directory contains the following files:
make_demo.bat |
Script that compiles the JSP Data Simulator. A sample JSP Data Simulator (gmsjsp/JspDemoSimulator.java) has already been compiled. If the JSP Data Simulator is recompiled, you must set the environment variable CATALINA_HOME to be your web server root directory and run the make_demo.bat script. |
make_war.bat |
Script called by make_demo.bat to create a web application archive. |
sample.jsp |
The Java Server Page that references the JSP Data Simulator class. |
xml_jsp_*.rtv |
RTView Display files. |
gmsjsp/JspDemoSimulator.java |
Sample JSP Data Simulator that outputs XML data. This file can be modified to output and update your own data. If you modify the file, you must set the environment variable CATALINA_HOME to be your web server root directory and recompile the simulator using the make_demo.bat script. |
1. In an initialized command window, go to the demos\dstutorial directory.
2. Copy the HTML files, displays files, and JSP Data Simulator class to your web server directory:
make_war |
This script creates a web archive (.war) named jspdata.war. |
install_to_tomcat jspdata |
This script installs the web archive jspdata.war to your Tomcat server. Note: This script will shutdown and restart Tomcat and requires administrative permissions. |
Note: If you are using a JSP servlet container other than Tomcat, install these files on your web server according to instructions given with that product.
The install_to_tomcat script will not work if the CATALINA_HOME environment variable has not been set. If you did not set this variable following product installation, then return to the product “Setup” section for details before continuing with this example.
Create a Display in the Display Builder
1. “Start the Display Builder” in your initialized command window.
In the Display Builder, begin by setting up substitutions for the JSP path.
2. Select Tools>Options to open the Application Options dialog and click on the Substitutions tab.
3. In the String field enter $jsp_path.
4. Enter the location of the jspdata directory when run through your web server (e.g.: http://myhost:myport/jspdata) in the Value field.
5. Click Add to insert this into your list of substitutions.
Next, setup the XML Sources.
6. Click on the XML tab.
7. If UnitTable is already defined in the XML Sources display, double-click on it. Otherwise, click Add.
XML Source Name - Enter UnitTable
XML Source Path - Enter $jsp_path/sample.jsp?unit=*
Contains Substitutions - Select the check box
Click OK to close the dialog.
8. Click Save
9. Select No when prompted to save the initialization file in the lib directory.
Next, add a label to the Working Area:
10. In the Object Palette window, select the Labels tab and click on the fifth label in the palette (class name: obj_label05).
11. To attach to data from the JSP Data Simulator, in the Object Properties dialog set the following properties for the object's label:
label - Right-click in the Property Name field and select Attach to Data>XML.
12. In the “Attach to XML Data” dialog, enter the following:
XML Source - Select UnitTable from the drop down menu
Data Key - Select Units from the drop down menu
Column(s) - Select Name
Filter - Select the check box
Filter Column - Select Name
Filter Value - Type A
Click OK to attach data and close the dialog.
13. To attach data to the object's value, set the following properties
value - Right-click in the Property Name field and select Attach to Data>XML.
14. In the Attach to XML Data dialog, enter the following:
XML Source - Select UnitTable from the drop down menu.
Data Key - Select Units from the drop down menu.
Column(s) - Select Status
Filter - Check the check box.
Filter Column - Select Name
Filter Value - Type A
Click OK to attach data and close the dialog.
The object's label should display the name of unit A and the object's value should display the status of unit A.
Next, set the command to update unit A:
15. In the Object Properties dialog, set the following:
command - Right-click in the Property Name field and select Define Command>System.
16. In the “Define System Command” dialog, enter the following:
Command Type - Select Execute URL from the drop down menu.
URL String - Enter $jsp_path/sample.jsp?unit=A?key=status?value=2
Click OK to apply the command and close the dialog.
17. To execute the command, double-click on the object.
The status should update to 2.
18. Select File>Save and name this display file as tutorial_jsp.rtv
19. Exit the Display Builder.
View Sample Displays in the Display Viewer
Sample displays (xml_jsp_data.rtv and xml_jsp_controls.rtv) are provided in the demos\dstutorial directory. These displays illustrate how to drill down to detailed displays, as well as how to use controls to update values on the server.
1. Open the Display Viewer by typing run_viewer in your initialized command window.
2. Login to the Display Viewer. By default, the Display Viewer does not require a login. “Login” can be enabled at setup to support “Role-based Security”. The default user name and password are:
User Name: admin
Password: admin
Note: It is possible that your system administrator may have configured another user name and password. In this case, you may also need to select a role. See “Role-based Security” for more information.
3. Double-click on the XML Displays folder in the tree.
4. Double-click on the Java Server Pages folder.
5. Select Get Data Via JSP in the tree to view the xml_jsp_data.rtv display.
If you did not complete the Setup procedures provided at the beginning of this example, you must select Setup in the tree before attempting to view other displays.
6. Click on a row in any of the tables to view the default drill down substitutions and to see more detailed information on these units.
7. Select Set Data Via JSP in the tree to view a display (xml_jsp_controls.rtv) that illustrates the use of controls to update values on the server.
8. Exit the Display Viewer.