Skip to main content

Introduction to CSP-Based Web Applications

InterSystems IRIS® data platform provides a technology that enables you to create web user interfaces. For historical reasons, this technology is known as CSP and the result is a CSP-based web application.

CSP intercepts HTTP requests before the browser sees them, and CSP provides an easy way to write directly to the browser. These factors mean that you have complete control over the web pages you generate. You can use CSP in conjunction with third-party JavaScript libraries if wanted, because you can simply add any needed JavaScript to your pages.

Components of a CSP-Based Web Application

From the point of view of an application developer, a CSP-based web application consists of the following elements on an InterSystems IRIS server:

  • A web application definition that is configured to use CSP/ZEN options instead of REST options.

    The web application definition controls things such as the allowed authentication mechanisms, the InterSystems IRIS namespace to run the code in, custom pages to use for specific purposes, timeouts, handling of static files, and more.

  • One or more CSP page classes. These classes generate full HTML pages in response to HTTP requests. A CSP page class has easy access to the request and to session information, and utility methods enable you to manage cookies, access CGI variables, and more.

  • External JavaScript files, style sheets, image files, static HTML files, and other resources as needed. These can live on the same server, can be on other servers, or can be a mix of both.

Architecturally, there are additional components:

  • A web server, as supported for use with InterSystems IRIS.

  • The Web Gateway, which acts as the intermediary between the web server and the InterSystems IRIS server or servers. The Web Gateway maintains a pool of connections to these servers.

    The Web Gateway configuration includes definitions of web applications running on the InterSystems IRIS servers. These definitions enable the Web Gateway to route requests to the correct web applications on the InterSystems IRIS servers (sending the requests via the CSP server, discussed next).

  • The CSP Server, which is a dedicated process running on an InterSystems IRIS server that waits for requests from the Web Gateway and then handles them as needed. Each InterSystems IRIS server may run as many CSP server processes as desired (subject to limits imposed by machine type; CSP servers are not counted in license calculations).

Information Flow

For a CSP-based web application, the request and return process is as follows:

  1. An HTTP client, typically a web browser, requests a page from a web server using HTTP.

  2. Because of how web server is configured, it recognizes the request as a CSP request and forwards it to the Web Gateway.

  3. The Web Gateway determines the InterSystems IRIS server to talk to and forwards requests to the CSP server on that target system.

  4. The CSP Server processes the request and determines whether the request is for a static file or for a CSP class.

    The CSP Server includes the Stream Server, which is the class %CSP.StreamServerOpens in a new tab. The Stream Server is responsible for handling files and other streams. If the request is for a static file, the Stream Server finds the file within the local file system, determines how to encode it, and packages it.

    If the request is for a class, the CSP server calls the Page() method of the class, which in turn calls the callback methods defined in that class.

  5. The CSP Server returns the requested content to the Web Gateway, which passes it back to the web server.

  6. The web server sends the content to the browser for display.

FeedbackOpens in a new tab