Active Server Pages

To embed a Corda® image into an Active Server Page (ASP), use the .NET version of Corda Embedder. Embedding a Corda image into an ASP can be broken down into the following steps:

The example code at the end of this section shows how to embed a Corda image in ASP.

Note: This documentation assumes that you are familiar with Active Server Pages.

Installing the Component

In order to use Corda Embedder in COM-aware environments such as ASP, register the .NET Corda Embedder as a COM component. This lets you access the .NET Corda Embedder from ASPs or other Web Applications that rely on COM.

Prior to doing this, you must first install the .NET SDK and then install the .NET Corda Embedder using the instructions in the text file located at <product_root>\Server\dev_tools\embedder\dotnet\COMInteropInstall.txt.

Delimiting the Code For a Corda Image

Delimit code for a Corda image as you do any other code or script in an ASP—with <% and %> (open angle bracket, percent sign and percent sign, close angle bracket), as in the following code segment:

<%

myImage.imageTemplate = "image_templates\examples\line.itxml"

myImage.loadITXML("http://<server_address>/?data1")

%>

ASP Syntax Differences

Note: The code syntax in this section is based on VBScript. If you script using JScript instead of VBScript, convert the code accordingly.

The examples in this documentation rely mostly on Java* coding conventions. For most developers, the corresponding ASP (VBScript) syntax should be fairly obvious, but we make a note of several syntax differences that may not be obvious. ASP (VBScript) gives a complete translation table of Corda Embedder ASP syntax.

Number of Parameters Not Optional

Limitations in the Component Object Model prevent setting default values for any parameters in Corda Embedder. Because of this, any method's optional parameters are required in Corda Embedder.

At this time, the methods this affects include loadData, loadCommandFile, loadMapData, and addHTMLTable.

If optional parameters are not needed, pass in empty strings for the unnecessary parameters. For example:

loadData "graph","prices.csv","replace","","".)

No Semi-colons at the End of Lines

Note: This applies to using VBScript in Active Server Pages, not to the .NET Corda Embedder in general. Ignore these instructions if you script with JScript.

Active Server Pages use VBScript, which requires that you do not have a semi-colon at the end of a line of code. Since other languages either require a semi-colon, or are indifferent, most of the example code in this documentation uses a semi-colon at the end of each line of code. Remove any semi-colons from example code when using it with ASP.

No Parentheses Around Void Methods

VBScript syntax requires any void methods to not have parentheses around the parameters. Remove any parentheses around void method parameters when using example code with ASP.

Instantiating a Corda Embedder Object

To instantiate a Corda Embedder object, use code similar to the following:

set myImage = Server.CreateObject("Corda.CordaEmbedder")

Setting the Server Information

Corda Embedder needs to know two Corda Server™ addresses: the address that the Web client uses to access Corda Server (externalServerAddress), and the address that Corda Embedder uses to access Corda Server (internalCommPortAddress). For more information about determining these addresses, see Identifying Server Addresses.

For example, if Corda Embedder communicates to Corda Server at 10.0.1.1:2002, and Web clients request images from http://<server_address>:2001, include the following in the code that generates the Corda image:

myImage.externalServerAddress = "http://<server_address>:2001"

myImage.internalCommPortAddress = "10.0.1.1:2002"

Specifying Image Information

After specifying server address information, give Corda Embedder some information about the Corda image you want to embed.

There are numerous Corda Embedder commands to specify image information, which are consistent in all Web application environments (with the exception of several syntax differences, as previously explained in ASP Syntax Differences). Thus, it is unnecessary to discuss each of these commands individually at this time.

The table below provides links to more information about Corda image features and components.

Topic

Where To Go

Annotations

Data Annotations in the Corda Builder™ User Guide

Content Delivery / Presentation Control

Image Deployment Issues and Descriptive Text Settings

Data

Connecting to Data Files and Connecting to Databases

Drilldown

Building Drilldown

Graph or Map Customization

Dynamically Customizing Graphs and Maps

Image Size & Format

Changing the Image Format and Changing Image Size

Writing the Image to a Web Page

When you are ready to write the embedding HTML to a Web page, place the following code segment at the location in the Active Server Page where you want the Corda image to appear.

<%= myImage.getEmbeddingHTML() %>

Note that it is opened with a <%= instead of just <%. The equals sign instructs the application server to write a string to the Web page, which in this case is myImage.getEmbeddingHTML(). There should be nothing else between the opening and closing angle brackets, as IIS expects only a string, not a code segment.

Complete Example Code

The code sample below demonstrates embedding a Corda image in an Active Server Page.

Note: To produce an example map instead of a example graph, replace examples/bar.itxml with examples/map/australia_combo.itxml in the code designating the Image Template file.

Embedding a Corda Image in an Active Server Page

<html>

<head>

<title>My First Embedded Image</title>

</head>

<body>

<h1>This is your image</h1>

<hr />

<!-- insert embedder code here -->

<%

set myImage = Server.CreateObject("Corda.CordaEmbedder")

myImage.externalServerAddress="<server address>:2001"

myImage.internalCommPortAddress = "localhost:2002"

myImage.imageTemplate = "image_templates\examples\bar.itxml"

myImage.width = 600

myImage.height = 400

myImage.pcScript = "title.setText(Hello World)"

%>

<%= myImage.getEmbeddingHTML() %>

<hr />

<p>If you see an image above, congratulations. You have successfully embedded your first image.</p>

</body>

</html>