Xap and Comet32
From CometWiki
m |
|||
Line 78: | Line 78: | ||
=====[[Get Query]] -- Retrieves the whole query from the Header or Post Data.===== | =====[[Get Query]] -- Retrieves the whole query from the Header or Post Data.===== | ||
=====[[Get PostData]] -- Retrieves Post Data.===== | =====[[Get PostData]] -- Retrieves Post Data.===== | ||
- | |||
- | |||
- | |||
- |
Latest revision as of 01:45, 26 June 2016
XAP the Easy, Fast way to Build and Serve Web Pages with Dynamic Comet Content
History
The first commercially available web page was published in 1995. Signature introduced the protocol lnown as XAP in 1998. XAP stands for eXtended Application Pages. It is the way to publish pages containing Your comet data.
The original XAP worked (and works) fine, although it is somewhat tedious to populate a web page with data. With the new functionality available in XAP2 and Comet32, this task is MUCH easier.
The Anatomy of a Web transaction
To more fully understand what is required in a web server (that is what XAP is), it is interesting to outline what a single transaction between the browser and the server looks like. For illustration, lets use the web address as http://localhost:8080/xap/xaptest/ as the url. This assumes we have xap running on our local machine.
Connect
The browser connects to the server. In this case it is connecting to localhost and it is listening to port 8080. Localhost is a universal DNS name for our own machine. its address is 127.0.0.1. This address is available on every windows machine, so it is convenient for everyone to use this address for testing.
Anyway, the browser connects to port 8080 in our case. The standard port for http is port 80, but in many cases windows takes this port for its own use.
The Header
Once a connection is made, the browser sends a block of text like this:
GET /xap/xaptest HTTP/1.1 Host: localhost:8080 Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24 Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Cookie: visits=101; loadtime=0.25
This is known as the HTTP Header. We are not interested in most of this stuff.
Our Response
We then send back a block of text. That completes the whole HTTP transaction. The parties disconnect, and the server waits for another transaction from anyone.
HTTP vs HTML
The block of text MAY be comprised of HTML or text in some other format (look at the "Accept:" line above. HTTP is the protocol (Hyper Text Transmission Protocol) and HTML stands for Hyper Text Markup Language.
Name/Value Pairs
Everything is names and values. Much of the data that comes from the browser is in the form of names and values. Name/Value pairs are delimited with one character and separated with another. The header above is delimited with crlf characters and the names and values are separated by colons. The cookies also are name/value pairs where the delimiter is a semi colon and the separator is an equal sign. The other set of data that we are interested in is the query string. That is delimited by ampersand characters and separated by equal signs.
Making it Easy for You
So, a single transaction with the browser consists of getting some data from it and sending a response back. There are several features of Comet32 that make this process easy.
Dynamic Strings
Comet32 Dynamic strings can be of any length (up to 4 GB or so). Data can be put into these strings without worry of overflowing. We can even read a whole file into a string for further processing. See InputFile.
Templates
Most of the data going to the browser is HTML. It is convenient to keep this HTML in a template. The template is divided into sections that will be handled separately by the program. Comet32 makes it easy to split a template into its sections and manipulate the section before sending it to the browser.
The Map Statement
Comet32 introduces the MAP statement which looks much like a format statement but is used to associate names with variables in your program (Values). The MAP statement is used in several high level functions and statements that make web programming easy (see below).