LiveWire compiles and links these files into an executable called a web file, with file extension .web.
<FORM METHOD="post" ACTION="hangman.html">LiveWire forms can use either "get" or "post" as the value of the METHOD attribute.
Note: LiveWire applications cannot perform file upload; that is, you cannot have an INPUT element of TYPE="file" that is submitted to a LiveWire application.
<SERVER>
and follow them by </SERVER>
. The tags can enclose a single statement or serveral statements. Do not use a SERVER tag inside another HTML tag (that is, actually inside the angle-brackets of the tag).
<A HREF=...>
, images <IMG SRC = ...>
, or form element tags. Do not use backquotes to enclose JavaScript expressions outside HTML tags.
<P>This time you are <SERVER> write(request.newname) client.oldname = request.newname </SERVER>The first line generates HTML based on the value of request.newname. If request.newname is "Mr. Ed," then it will generate the following HTML:
<P>This time you are Mr. Ed.The second line in the example simply performs a JavaScript statement, assigning the value of request.newname to client.oldname. It does not generate any HTML.
<TAG ATTRIB="value" [...ATTRIB=VAL]>where ATTRIB is an attribute and
"value"
is its value. The bracketed expression indicates that there can be any number of attribute/value pairs.
Use backquotes (`) to enclose JavaScript expressions as substitutes for HTML attribute names or values. When you embed JavaScript in HTML with back-quotes, it automatically emits HTML; you do not need to use write.
For example, consider the following line from the "Hangman" sample application:
<IMG SRC=`"images/hang"+client.num_misses+".gif"`>This line dynamically generates the name of the image to use based on the value of client.num_misses. The backquotes enclose a JavaScript expression that concatenates the string
"images/hang"
with the integer value of client.num_misses and ".gif"
. The result is a string such as "images/hang0.gif"
or "images/hang1.gif"
. JavaScript automatically converts the integer value to a string. The result is HTML such as
<IMG SRC="images/hang0.gif">The order of the quotation marks is critical. The backquote comes first, indicating that the following value is a JavaScript expression, consisting of a string (
"images/hang"
), concatenated with an integer (client.num_misses), concatenated with another string (".gif"
). JavaScript converts the entire expression to a string, and LiveWire adds the neccessary quotes around the attribute value. You cannot put a JavaScript expression for an attribute value inside double quotation marks, because it would be interpreted as the literal attribute value.
LiveWire automatically adds quotation marks around an attribute value when you enclose a JavaScript expression in backquotes, therefore do not provide them yourself (except for string literals, as in the preceding example).
For example, the anchor tag has attributes called HREF and NAME, among others. HREF makes the tag a hyperlink, and NAME makes it a named anchor. You could use the following script to create either a hyperlink or a target, depending on the value of the attrib and val properties of client:
<A `client.attrib` = `client.val`> Netscape Communications </A>You could use the following code before the preceding statement to set the properties according to a request variable:
<SERVER> if (request.choice == "link") { client.attrib = "HREF" client.val = "http://www.netscape.com" } if (request.choice == "target") { client.attrib = "NAME" client.val = "NetHead" } </SERVER>If request.choice is
"link"
, the result would be
<A HREF="http://www.netscape.com"> Netscape Communications </A>If request.choice is
"target"
, the result would be
<A NAME="NetHead"> Netscape Communications </A>In both cases LiveWire adds the quotation marks around the attribute values produced in HTML.
<IMG SRC=`"images/hang"+client.num_misses+".gif"`>you could write
<SERVER> write("<IMG SRC=\"images/hang") write(client.num_misses) write(".gif\">") </SERVER>Notice the backslash that lets you use a quotation mark inside a literal string. While the resulting HTML is the same, in this case, backquotes are preferable, because the source is easier to read and edit.
Note: Only sites that have pages containing server-side JavaScript need to be compiled.
lwcomp [-c|v|?] [-o outfile.web] [script1.html ..scriptn.html] [funct1.js ..functn.js]Items enclosed in square brackets are optional. The syntax is shown on multiple lines for clarity. There must be at least one HTML file or JavaScript source file.
For example, the following command compiles and links two LiveWire pages, main.html and hello.html and a JavaScript file support.js, creating a binary output file named myapp.web:
lwcomp -v -o myapp.web main.html hello.html support.js
Installing a new application
After you build an application, you must install it with LiveWire Application Manager to make it accessible to clients. Installing an application identifies it to the server.
To install a new application, click the Add button in Application Manager. The right frame of Application Manager will display a form in which you enter the application name, path to the web file, and other installation parameters.
Important: Before you install an application, be sure the application name that you pick will not to usurp an existing URL on your server. LiveWire will route all client requests for URLs that match the application URL to the directory specified for the web file. This will circumvent the server's normal document root.
For more information on installing applications, see "Installing a new application" on page 22.
Restricting access to an application
You may want to restrict the users that can access a particular application. You can do this by applying a server configuration style to the application. For more information on styles, see your server Administrator's Guide.
Starting, restarting, and stopping an application
After you first install an application, you must start it to run it. Select the application in Application Manager and click Start. If LiveWire successfully starts the application, the status of the application will change from "stopped" to "active" in the right frame.
You can also start an application by loading the following URL:
http://server.domain/appmgr/control.html?name=appName&cmd=start
where appName is the application name.
You must restart an application each time you rebuild it. To restart an active application, select it in Application Manager and click Restart. Restarting essentially re-installs the application; LiveWire will look for the specified web file. If there is not a valid web file, then LiveWire will generate an error.
You can also restart an application by loading the following URL:
http://server.domain/appmgr/control.html?name=appName&cmd=restart
If you want to stop an application, to make it inaccessible to users, select it in Application Manager and click Stop. You can also stop an application by loading the following URL:
http://server.domain/appmgr/control.html?name=appName&cmd=stop
Running and debugging an application
Once you have compiled and installed an application, you can run it by
The server then generates HTML for the specified application page, and sends it to the client.
For convenience, bookmark these URLs when developing an application.Instead of using Application Manager, it may be more convenient to use an application's debug URL instead. To display an application's trace facility in a separate window, enter the following URL:
http://server.domain/appmgr/trace.html?name=appNamewhere server.domain is your server and domain name and appName is the name of the application. To display the trace facility in the same window as the application (but in a separate frame), enter this URL:
http://server.domain/appmgr/debug.html?name=appNameYou must have access privileges to run Application Manager to use these URLs.
debug("Current Guess is ", request.guess)displays the value of the guess property of the request object in the trace window along with some identifying text.