11.4. Connecting Browser Applications

Web applications can acquire real-time information from the DataHub Web Server using two methods:

11.4.1. ASP Document Requests

An ASP document is a primarily static document with script snippets embedded within it using a special syntax:

  • <%= expression %>  (With an = sign) Evaluates the expression and inserts the result as a string into the output document, replacing all characters from the opening <%= to the closing %>. The expression is not a complete statement and must not end with a semicolon character or other statement completion syntax. For example, 3 + 2 is an expression. x = 3 + 2; is a statement.

  • <% statement or fragment %>  (Without an = sign) Evaluates the statements within the delimiters, and deletes all characters in the output document from the opening <% to the closing %>. The code within the delimiters does not need to be a complete statement. A single statement could be split across multiple occurrences of the <% %> pair. This allows you to, for example, create a loop that mixes literal text with computed values by breaking the opening and closing braces of the loop body across multiple <% %> regions. The concatenation of all statements and statement fragments must form a syntactically correct script.

  • All other characters  All characters, including white space, not contained within <%= %> or <% %> pairs are treated as literal text and simply copied to the output document.

When an ASP document is evaluated, all code within the special delimiters is evaluated to construct the output document. This document is then returned to the originator of the HTTP request.

ASP scripts run in the same global context as all other Gamma scripts, meaning that they have full access to other functions and scripts you define. It also means that a long-running script within an ASP page will delay other scripts. It is a good idea to keep the run-time of ASP scripts low.

The resulting output from an ASP document does not need to be valid HTML. It could be JSON, XML, plain text, or any text format that the client application requires.

Place your ASP documents in the folder {config}\WebContent or one of its sub-folders, where {config} indicates the folder containing your DataHub instance configuration, and WebContent will be treated as the root of the HTML file system.

ASP documents must be named with a .asp extension.