When using Corda®
Builder™ to create dynamic Corda images with Corda Server™, you can jump-start
the Web deployment process by letting Corda Builder automatically generate
the code needed to embed a dynamic Corda image in a Web page. Simply load
or create an Image Template file, and then click the Sample
Code button
in the Corda Builder toolbar. The Sample
Code Editor generates a complete example Web page for the Corda image.
Important: Save the Image Template file before creating the sample Web page. If Corda Server is running on a different computer, save the Image Template file to the computer running Corda Server.
The Sample Code Editor generates example code for a variety of environments (JSP, ASP, PERL, PHP, ColdFusion*, .NET, and standard HTML) using Corda Embedder to create and display the Corda image within the Web page. The Sample Code Editor also lets you to specify important variables, such as the image type and a server address.
The generated sample code can be saved directly to a Web server, where it works immediately; however, it is more usual to further customize this code before publishing the Corda image. Either way, the Sample Code Editor can save you a lot of time when generating code. It's also a great learning tool.
Note: Except for the ASP, ColdFusion and HTML options, a Corda Server administrator needs to install Corda Embedder for the example code to work. For information about installing Corda Embedder, see Installing Corda Embedder in the Corda 7 Install and Administration Guide.
There are several buttons and options in the Sample Code interface. The table below describes each item.

|
Item |
Description |
|
Sample code for |
Select the target environment for the sample code from the drop-down list. |
|
Server URL |
Specifies the Corda Server address. If Corda Server is running locally, leave this value as http://<server_address>:2001. If you don't know where Corda Server is running, ask the Corda Server administrator, or see Identifying Server Addresses in the Corda 7 Developer Reference. |
|
Comm Port |
Specifies the Corda Server's comm port address. If the Corda Server is running locally, leave this value as http://localhost:2002. If you don't know where Corda Server is running, ask the Corda Server administrator, or see Identifying Server Addresses in the Corda 7 Developer Reference. |
|
Output Type |
Specifies the output type for the Corda image. Options include JPEG, FLASH, and SVG*. |
|
Use Best Image Fallback |
Enables best image fallback, which detects the plug-ins a browser has and allows the Web browser to always show a Corda image using the best possible image format supported by that Web browser. For more information see Best Image Fallback in the Corda 7 Developer Reference. |
|
Show Database Connectivity Sample Code |
When selected, this option inserts sample code for database connectivity. This code refers to the CordaSamples database that is installed by default on most Windows* systems. In fact, if you use it on a Windows system, the sample page/Web application actually connects to the CordaSamples database. However, most database programmers find it fairly easy to modify this code to connect to their own database. To learn more about the CordaSamples database, see Corda 7 Sample Databases in the Corda 7 Install and Administration Guide. |
|
Select Code File (for ASPNET samples) |
Shows either the HTML source for the Web page (the .aspx file), or the .NET code behind the Web page (the .aspx.cs or .aspx.vb file). |
|
Server Commands (for HTML samples) |
Specifies that these pages use server commands instead of Corda Embedder to request a Corda image. This allows you to specify the method used to send server commands to Corda Server.
|
|
Save Preferences |
Saves the sepcified settings for Server URL, Comm Port, Code type and Image Type, as default Sample Code preferences. |
|
Save Code to File |
Saves the displayed sample code to a file. |
|
Copy Code to Clipboard |
Copies the sample code displayed in the Sample Code window to the system clipboard. |
|
Save Sample Data File(s) (for map images only) |
Saves a sample data table to the CordaSamples database. This sample data table is compatible with the map you are currently using. If the CordaSamples database is not installed, Corda Builder saves the data as a CSV file in <document_root>\examples\data (see the Show Database Connectivity Sample Code option above). |
The following process tests an Image Template file with the example code generated for the JSP Corda Embedder. You must have Corda Server running locally for this to work as described.
Note: These instructions can be used with most Web application environments (ASP, Java*, etc.), by saving the file to the appropriate Web application server.
To test the Image Template file with the Java Corda Embedder
Start Corda Builder.
Load or create an Image Template file.
Click the Sample
Code button
on the toolbar.
In Sample Code For, select JSP (Java embedder).
Select Save Code to File.
Specify a file name and save it.
To serve this page from a Web server, save it to (or subsequently upload it to) a Web-enabled directory.
Start Corda Server locally.
View the Web page that you saved in step 6 in a Web browser.
If you don't see a Corda image, make sure Corda Server has been started, and that it is running at http://<server_address>:2001. If it is running on a different machine, change the Server URL value in the sample code dialog, and upload the Image Template file to Corda Server.
For more information about embedding Corda images, see Using Corda Embedder in the Corda 7 Developer Reference.