One of the many ways to request images from your Corda Server™ is via the Corda® Redirector servlet. By using your Web application server in conjunction with the Corda Redirector servlet, you gain the ability to communicate using Secure Sockets (SSL) and eliminate the need to expose another port outside of your firewall. All communication from Web clients to your Corda Server pass through the Corda Redirector servlet.
Corda 7 includes a convenient Corda Redirector Web application to ease the installation process. Before installing the Corda Redirector, configure this Web application to point to Corda Server.
To configure the Corda Redirector Web application
Open the dev_tools/redirector/servlet/ctredirector/WEB-INF/web.xml file in a text editor.
Locate the CordaServer initialization parameter, and change its value to the address and port of your Corda Server.
For example, if your Corda Server runs over port 2001 at 10.0.1.53, you would set this value as follows:
Registering the Servlet Redirector with the Tomcat web.xml File
<Web-app>
<servlet>
<servlet-name> CTRedir </servlet-name>
<servlet-class>com.corda.ctRedirector</servlet-class>
<init-param>
<param-name>CordaServer</param-name>
<param-value>10.0.1.53:2001</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CTRedir</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</Web-app>
Save this file and close it.
After configuring the Corda Redirector Web application, deploy it on your Web application server. This section offers deployment instructions for the Corda Redirector with the following Java-enabled application servers:
Note: Once you've installed the Corda Redirector, be sure to modify your Corda Embedder code or HTTP requests to your Corda Server so that they use the address of the Corda Redirector instead of the address of the Corda Server, as described in Using HTTP Redirection.
These instructions apply to the iPlanet / Sun One series of Web application servers.
To install the Corda Redirector on iPlanet / Sun One
Make sure you have configured the Corda Redirector Web application, as instructed in Configuring the Corda Redirector, above.
Open your server's Web-apps.xml file in a text editor.
The Web-apps.xml file is usually located in the iPlanet/Servers/https-myserver/config directory, where myserver represents the name of your server. For example, if your server is named jaguar, this folder would be iPlanet/Servers/https-jaguar/config .
Insert the following <Web-app> tag into the <vs> tag:
<Web-app uri="/ctRedirector" dir="webapplication" />
Replace webapplication with the folder for the pre-packaged Corda Redirector application. Usually, the pre-packaged application folder is located in your Corda Server installation at dev_tools/redirector/servlet/ctredirector.
For example, if Corda 7 is installed at C:\Corda\7, the resulting Web-apps.xml file might look like that in the example below:
iPlanet / Sun One Web-apps.xml File
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vs PUBLIC "-//Sun* Microsystems, Inc.; iPlanet//DTD Virtual Server Web Applications 6.0//EN" "http://developer.iplanet.com/webserver/dtds/iws-webapps_6_0.dtd">
<vs>
<web-app uri="/ctRedirector" dir="C:/Corda/7\Resources/dev_tools/redirector/servlet/ctRedirector"></Web-app>
</vs>
Save this file and close it.
Restart the iPlanet / Sun One server.
To test your installation, browse to the address http://localhost:81/ctRedirector, where localhost:81 is the address and port on which your iPlanet / Sun One server runs.
If you see the Corda Server splash screen, you have successfully installed the Corda Server Servlet.
These instructions apply to Apache Tomcat application servers.
To install the Corda Redirector on Tomcat
Make sure you have configured the Corda Redirector Web application, as instructed in Configuring the Corda Redirector, above.
Locate the Tomcat's Web application folder.
Usually this is the /webapps folder inside your Tomcat installation directory.
Copy the dev_tools/redirector/servlet/ctRedirector directory to this folder.
This means that you have a webapps/ctRedirector folder inside of Tomcat.
Restart Tomcat.
To test your installation, browse to the address http://localhost:8080/ctRedirector, where localhost:8080 is the address and port on which Tomcat runs.
If you see the Corda Server splash screen, you have succesfully installed the Corda Server Servlet.
In most cases, install Corda Redirector by deploying the Web application located in <product_root>\Server\dev_tools\redirector\servlet\ctRedirector. Check the application server's documentation to find out how to deploy a Web application.
If you are unable to deploy the pre-packaged Web application, manually install the Corda Redirector. The Corda Redirector is in the <product_root>\Server\dev_tools\redirector\servlet\WEB-INF\lib\ctRedirector.jar file. The class for the servlet is com.corda.ctRedirector . It requires one initialization parameter, CordaServer, which should be set to the address and port of Corda Server.
Consult the application server's documentation for information on configuring a servlet.
To properly set the initialization parameter, change the value in the <param-value> tag to match the address and port of the machine running your Corda Server.
If the servlet is not functioning properly, you either receive an error message when you try to test the servlet or see a message displayed on the Web server's console. Below are two common errors that you might find:
This error typically occurs if you have not put the ctRedirector.jar file in the correct directory structure or if you haven't restarted the Web application. The .jar file must be in the right directory for servlets and must also be registered with your Web application server. See your Web applications server's documentation to correct this problem.
This error occurs in a Web browser if the servlet cannot contact the Corda Server running on the localhost port 2001. You may need to create a CordaServer init parameter for your environment (see Configuring the Corda Redirector above). The directions listed in the browser with this error should help to correct this problem.