A "Hello World" app for the JHS (J HTTP Server) in J701 (Beta)
Just to record my current understanding of the sort of app which JHS lets you write, in the hope it might help others get started quickly, here is my attempt at a trivial "Hello World" app for JHS (the J HTTP Server) in its present form.
What it contains:
How to use it
1. Start J701 using the JHS IDE
2. Enter: load '~user/hello.ijs'
This will create a locale: hello.
3. Open a new browser tab and enter the URL: http://127.0.0.1:65001/hello
- This will run the app, showing a very simple page (if you don't see it, press the browser's "refresh page" button):
4. Study jdemo.ijs which comes as part of the JHS addon, to see how to elaborate this example.
How it works (I think...)
When the J server gets the URL, it looks for and runs jev_get'' inside the locale: hello.
If there is no such verb then the following message is output to the jijx session:
|value error: jev_get_hello_ | jev_get_hello_'' *** response not sent for hello *** html404 (URL not found) sent
...but you might have to enter an empty line in jijx before you see it.
jev_get_hello_ (jev_get inside the locale: hello) is typically assigned a verb always called: create which creates and sends the HTML page in response to the URL.
Verb jhr (in locale jhs), called by: create, creates the HTML of the page.
It takes a left arg: the page title (which usually appears in the browser tab). Its right arg is a specification to replace tags, eg <REPLACE>, which is shown here but unused in this simple example.
To do this, jhr makes use of three nouns:
HBS containing the page layout in a symbolic form (see jdemo.ijs examples)
CSS containing any special styles needed
In the present case HBS is a very simple layout, and both CSS and JS are set to ''
Scripts jdemo.ijs and the scripts that go with it, notably jdemo4.ijs, have examples of non-trivial CSS and JS.
If you haven't installed the J701 Beta, you can download this script here (for visual inspection only of course, because it won't usefully run under J602):
-- IanClark 2010-11-06 05:50:58