If you use JSPs to deliver Web content, you can embed Highwire™ links using the Java* Corda® Embedder or the Corda Embedder Java Tag Library
Embedding a Highwire link into a JSP via the Corda Embedder Java Tag Library can be broken down into the following steps:
The example code at the end of this section shows you how a Java Server Page would look using the Java Tag Library Corda Embedder to create a Highwire link.
Note: This documentation assumes that you have set up a Java-extensible Web application server and that you are familiar with Java tag libraries.
Before importing the Corda Embedder library into a JSP, first make sure that the CordaEmbedder.jar file, located in the dev_tools/embedder/java folder, is in the classpath for the Web application. For more informaiton, see Java Application Servers in the Corda 7 Install and Administration manual.
Some older Java application servers need to explicitly install the Java tag library for the Web application. If the sample code in this section fails to work, follow the instructions outlined in Java Tag Library in the Corda 7 Install and Administration guide.
You delimit the tag library code for the Highwire link with <ctl:Corda> and </ctl:Corda> tag, as in the following code segment:
<ctl:Corda loadDoc="examples/html/asset.html" />
Note that all of the Corda Embedder code should be placed within one <ctl:Corda> tag. The majority of Corda Embedder settings are set as attributes of the <ctl:Corda> property, but some are set as properties contained by <ctl:Corda>.
Most of the example code in this manual assumes that you are using the Java Corda Embedder. To make the example code applicable to Java tag libraries, convert the syntax.
If you need to find the Java tag library equivalent of any statement, look it up in Java_Tag_Library Alternate Syntax in the Corda 7 Developer Reference. The following syntax conversion rules may be helpful:
Corda Embedder attributes can be translated into Corda Tag Library syntax by simply creating an attribute in the <ctl:Corda> tag with the same name as Corda Embedder attribute that you want to use.
<ctl:Corda externalServerAddress="http://<server_address>:2001" internalCommPortAddress="http://localhost:2002" />
For the most part, Corda Embedder methods can be translated into Corda Tag Library syntax by simply creating a property within <ctl:Corda> with the same name as Corda Embedder method that you want to use. Then, pass the parameters of the method as attributes to the tag
<ctl:Corda>
<ctl:method param="value" param2="value2" />
</ctl:Corda>
However, this is not always the case. The , method follows these rules except for the parameters setting the actual document. Since this parameter can grow to be fairly big, it should be specified as a property contained by setDoc, as shown below:
<ctl:setDoc basepath="http://myserver.com/test" encoding="utf-8"><html><head>...</ctl:setDoc>
To instantiate a Corda Embedder object, use the following line of code (this assumes that you want to name the object ctl).
<%@ taglib uri="com.corda.taglib" prefix="ctl" %>
In order to use the Corda Embedder you must first tell it the location of Corda Server™ .
You need to set two values: 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 example, if the Corda Embedder communicates with Corda Server at 10.0.1.1:2002, and Web clients request documents from http://myserver.mycompany.com:2001, you need to include the following attributes in the <ctl:Corda> tag:
<ctl:Corda externalServerAddress="http://myserver.mycompany.com:2001" internalCommPortAddress="http://10.0.1.1:2002" />
Your Corda Server administrator should be able to tell you what values you need to use for these settings. If you are having trouble figuring these values out, see Identifying Server Addresses in the Corda 7 Developer Reference.
After you have specified the server address information, give the Corda Embedder some information about the Corda image you want to create.
The most important piece of information you need to provide is the location of the Web document you want to convert. Do this using the Corda Embedder loadDoc method.
<ctl:Corda loadDoc="examples/html/asset.html" />
This allows us to specify the URL directly, but it unfortunately decreases the portability of the JSP—you'll have to change the code if you ever change the location of the Web application.
There are a number of other Corda Embedder commands for specifying document information. Fortunately, these commands are consistent in all Web application environments. Thus, it is unnecessary to discuss each of these commands individually at this time. For more information, see Other Topics in this manual, and Corda Embedder API in the Corda 7 Developer Reference.
When you are ready to write the document to a Web page, simply close the <ctl:Corda> tag. The Corda Embedder tag library then writes the document to the Web page.
The following Java Server Page produces a Web page that contains a link to a Highwire document. When you click this link, Corda Server translates the Web page to PDF.
Embedding a Highwire Link in a Java Server Page (Tag Library)
<%@ taglib uri="com.corda.taglib" prefix="ctl" %>
<html>
<head>
<title>My First Highwire Document</title>
</head>
<body>
<h1>This is a very simple Web page</h1>
<hr />
<p>Click below to convert this page to PDF using Corda Server's Highwire.</p>
<!-- insert Embedder code here -->
<ctl:Corda externalServerAddress="http://<server_address>:2001" internalCommPortAddress="http://localhost:2002" loadDoc="examples/html/asset.html" />
</body>
</html>