One of the key strengths of I*Tea lies in its pre-defined automated policies of Web Client context management.
I*Tea automatically identifies every browser with an HTTP cookie key (setting it only once at the beginning of the client's session), and from there on it manages its internal context data pools for each HTTP request automatically. The programmer has no need to worry about identifying separate client sessions.
I*Tea provides a simple get/set key value API for storing simple Client Data state information. In some cases, this is enough to easily store client dependent application state. In such cases, the programmer can configure the I*Tea Server to have a limited pool of Tea Interpreter Context , which can be used to cache data and code common to all users.
In the cases where the effort for serializing individual Web Client application state is considered high, it is recommended that the programmer configures the I*Tea Server to allocate a private Tea Interpreter Context for each Web Client session. In this case, the programmer sees a full client-server programming model, where, each Web Client appears to have a single server process just to itself.
As a simple example of I*Tea code for a simple HTML counter. Tme implementation is exptrmely simple. Just a library file counter.tea
define counter 0
# Like C's "static int counter = 0;"
global incrementAndPrint () {
set! counter [+ $counter 1]
doc-print $counter
}
# Like C's "void incrementAndPrint() {
# counter = counter + 1;
# printf("%d", counter);
# }"
and the server side parsed HTML file counter.html
<HTML><BODY>
Counter value is: <!--@
import "counter.tea"
incrementAndPrint
--></BODY></HTML>
Each Web Client sees its own counter, and every time they attempt to read
counter.html I*Tea identifies the Web Client and chooses apropriate
context for the variable counter.
In this latest case, as Tea and Java libraries are dynamically imported for each Web Client session, for large software projects the time spent on importing vast library definitions can become high. Tea supports a library import-on-demand feature to ease such problem, but, besides that, I*Tea supports an operating mode where each Tea Interpreter Context can be reused for another Web Client when the previous client has releases the session (though logout or timeout). Such a new session already has all the libraries from the previous Web Client imported.