Instead of using Corda® Embedder to embed a Corda image in a Web application, deliver the Corda image directly via a Web application. To do this, use Corda Embedder's getBytes method to send all formatting options to Corda Server™, which creates the Corda image and returns it to the Web application in a byte array.
The code below, for example, illustrates the getBytes() method in Java*:
byte ba[] = myImage.getBytes();
ServletOutputStream os = response.getOutputStream();
os.write(ba,0,ba.length);
os.close();
When using this method, set the proper mime type for the image you want to return. For example, to return a JPEG image, set the mime type to image/jpeg. Table of MIME Types in the Corda Builder™ User Guide lists the mime types for each of Corda 7's image formats. If you do not know how to set the mime type for a Web application, refer to the Web application's documentation.
Important: Be sure not to return any text other than the results of getBytes() to the Web browser. Any additional text results in a corrupted image.
The sample code below shows complete code for returning a Corda image in a JSP:
Returning a Corda image from a JSP
<%@ page contentType="application/shockwave-flash" %>
<%@ page import="com.corda.CordaEmbedder" %>
<%
CordaEmbedder myImage = new CordaEmbedder();
myImage.externalServerAddress = "http://<server_address>:2001";
myImage.internalCommPortAddress = "http://localhost:2002";
myImage.imageTemplate = "image_templates\examples\bar.itxml";
myImage.outputType = "FLASH";
byte ba[] = myImage.getBytes();
ServletOutputStream os = response.getOutputStream();
os.write(ba,0,ba.length);
os.close();
%>
Thesample code below shows complete code for returning a Corda image in ASP:
Returning a Corda image from an ASP
<%
Response.ContentType="application/shockwave-flash"
set myImage = Server.CreateObject("Corda.Embedder")
myImage.externalServerAddress = "http://<server_address>:2001"
myImage.internalCommPortAddress = "http://localhost:2002"
myImage.imageTemplate = "image_templates\examples\bar.itxml"
myImage.outputType = "FLASH"
Response.Clear
Response.BinaryWrite myImage.getBytes()
%>