This section describes embedding a graph dynamically within a JSP. To do this, use an Image Template file, which is a template for dynamically generated Corda® images, to create a basic JSP using Corda Builder's sample code feature. A small segment of Java* code in this JSP allows you to publish the Corda image to the Web.
Initially, publishing a graph uses that graph's static data. Once published, connect the graph to a dynamic data source, as described in Connecting to Data.
Important: This tutorial discusses a Corda image containing a graph. However, the same process applies equally well to Corda images containing maps.
Note: This tutorial takes approximately 15 minutes.
To Publish a Basic Corda Image
Open an Image Template file in Corda Builder™.
Use any existing Image Template file. Image Template files are in <document_root>\image_templates. For more information, see About Image Template Files in the Corda Builder User Guide.
Note: Do not use a time graph, X-Y graph, Stock graph, Box Plot, or gauge Image Template file with this tutorial. Those types expect data to be organized differently, and therefore do not work with the instructions in Connecting to Data.
Click the Sample
Code button
in the Corda Builder toolbar.
Select JSP (Java Embedder) in the Sample Code for drop-down menu.
This is the sample code for embedding a Corda image in a Web page using the Image Template file you just opened.
This particular code uses the Java Corda Embedder in a JSP. The Corda Embedder is a utility available for many different Web environments that simplifies the process of embedding a Corda image in a Web page. For more information about using the Corda Embedder, see Using Corda Embedder.
Note: Most published graphs benefit from dynamic special effects to better display the data. Do this by inserting a few more lines of code into the JSP you're creating. For information about special effects like drilldown, data labels, and hover text, see Dynamically Customizing Graphs and Maps and Building Drilldown.
(Conditional) If you are running Corda Server™ on a computer other than the one you are currently using, change the Server URL and Comm Port paths to reflect the correct Corda Server address.
For more information on Corda Server addresses, see Identifying Server Addresses.
From the Output Type list, select an image format for the graph (JPEG, Flash*, or SVG*).
Save this code by clicking Save Code to File. Save it to a folder from which you can serve JSPs.
This tutorial assumes you save the file as C:\Webapps\ROOT\Chart1.jsp, which is in the default Apache Tomcat application server root directory.
If you do not know where you need to save this file, ask your systems administrator, or refer to the Java Application Server's documentation.
(Conditional) If Corda Server and the Java Application Server are not running on the same machine, make sure that the Corda Embedder library is installed on the Java Application server.
For more information, see Java Application Servers in the Corda 7 Install and Administration manual.
Make sure that Corda Server is running.
For more information, see Starting Corda Server in the Corda 7 Install and Administration manual.
(Conditional) If Corda Server and Corda Builder are not running on the same system, upload the Image Template file to the equivalent folder in the Corda Server document root directory.
The default Image Template file location is <document_root>\image_templates. For more information, see Installing Image Template Files in the Corda 7 Install and Administration manual.
Open Chart1.jsp in a Web browser to display the graph from the Image Template file.
If you do not know what URL to use to view the JSP file, ask your systems administrator or refer to the Java Application Server's documentation.
If you receive any errors when requesting the image, review the preceding steps carefully to make sure they were followed completely. The most common problems are:
You either did not restart the Java Application Server after installing the Corda Embedder, or you did not install it correctly (or in the right folder for your Web application). The Java Application Server's error log and/or documentation can help correct this problem.
Corda Server failed to start correctly. Usually, you receive an error message from Corda Server when this occurs. For more information, see Starting Corda Server in the Corda 7 Install and Administration manual.
This image contains static data. For information on connecting this graph to a dynamic data source, see Connecting to Data.