Using HTTP Redirection

When you use HTTP redirection, all client communication with PopChart Server is handled by the web server. From a security standpoint, this means that when you talk to PopChart Server, you inherit the same security settings that your web server has.

From a development standpoint, the main consequence of this is that all requests to PopChart Server should be made to the PopChart module on the web server itself.

For example, suppose that you are running PopChart Server on the same machine as your web server, http://www.mycompany.com. Without a redirector, a client would use this address to communicate with PopChart Server: http://www.mycompany.com:2001. With a redirector, a client can request a PopChart image from an address similar to the following: http://www.mycompany.com/popchart.dll (for the ISAPI redirector for IIS) or http://www.mycompany.com/servlet/popchart (for the Servlet redirector).

Notice that by using the redirector, we no longer have to use port 2001. To the client, it appears that PopChart Server is running over the web server port (80). In the PopChart Embedder, this means that instead of setting your externalServerAddress attribute to http://www.mycompany.com:2001, you would set it to http://www.mycompany.com/scripts/popchart.dll, as illustrated in the following line of code.

myPopChart.externalServerAddress = "http://www.mycompany.com/scripts/popchart.dll";

Note: The JavaScript PopChart Embedder does not use externalServerAddress. Instead, if you are using a redirector, you will request the jsEmbedder (refer to "Importing the PopChart Embedder Library") from this address.

This does not affect the internalCommPortAddress, however. The PopChart Embedder uses a separate port (the comm port, 2002), and cannot communicate with PopChart Server through a redirector. Since the web application that uses PopChart Embedder will also be behind the firewall, a redirector is not necessary.

How it Works

If you are confused about how the PopChart Embedder works, consider the following setup. Your web server is located at http://popchart.mycompany.com. On this web server, you have a web page called stats.asp that uses PopChart Embedder to embed a PopChart image. PopChart Server is on a machine behind the firewall at 10.0.1.2, using its default port settings (server port = 2001, comm port = 2002). You have setup the ISAPI PopChart redirector on your web server.

In this situation, in your PopChart Embedder code, you should set the externalServerAddress and the internalCommPortAddress attributes as follows:

myPopChart.externalServerAddress = "http://popchart.mycompany.com/scripts/popchart.dll";

internalCommPortAddress = "10.0.1.2:2002";

When a client requests the stats.asp page from the web server, PopChart Embedder will send an image request to PopChart Server over port 2002 at the address 10.0.1.2. PopChart Server will generate the image and return to PopChart Embedder the HTML necessary for the client to request the image. PopChart Embedder will write this to the web page, and the web server will send the page on to the client.

In the web page, the client will see a tag similar to the following.

<img src= "http://popchart.mycompany.com/scripts/popchart.dll?12345"/>

It will then request an image from the address http://popchart.mycompany.com/scripts/popchart.dll. The web server receives this request and redirects it to port 2001 at the address 10.0.1.2, which is PopChart Server's server port. PopChart Server will see the query string, fetch the image, and send it back to the web server, which then forwards it on to the client.