| <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
| <HTML> |
| <HEAD> |
| <TITLE>dispatch_1</TITLE> |
| </HEAD> |
| <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#1F00FF" ALINK="#FF0000" VLINK="#9900DD"> |
| <A NAME="top"> |
| <A NAME="file1"> |
| <H1>dispatch_1.ws3</H1> |
| |
| <PRE> |
| <I><FONT COLOR="#B22222"># register the websh command "pricelist" |
| </FONT></I>web::command pricelist { |
| |
| <I><FONT COLOR="#B22222"># web::put sends string to the default output channel |
| </FONT></I> <I><FONT COLOR="#B22222"># (stdout in the CGI case), including HTTP headers |
| </FONT></I> web::put {<tt><h2>price <B><FONT COLOR="#A020F0">list</FONT></B></h2></tt>} |
| |
| <I><FONT COLOR="#B22222"># web::cmdurl produces a URL with querystring. In this case, |
| </FONT></I> <I><FONT COLOR="#B22222"># we just want to switch back to "default", that's why we omit |
| </FONT></I> <I><FONT COLOR="#B22222"># an explicit command name and just use "" |
| </FONT></I> web::put <B><FONT COLOR="#BC8F8F">"<a href=\"[web::cmdurl "</FONT></B><B><FONT COLOR="#BC8F8F">"]\">back</a>"</FONT></B> |
| } |
| |
| <I><FONT COLOR="#B22222"># register the websh command "default" |
| </FONT></I>web::command default { |
| <I><FONT COLOR="#B22222"># welcome note |
| </FONT></I> web::put {<tt><h2>hello, customer</h2></tt>} |
| <I><FONT COLOR="#B22222"># link to an other HTML page of this application, the price list. |
| </FONT></I> <I><FONT COLOR="#B22222"># We generate the URL using web::cmdurl and specify the command |
| </FONT></I> <I><FONT COLOR="#B22222"># to be used: it is called pricelist and has been defined above. |
| </FONT></I> web::put <B><FONT COLOR="#BC8F8F">"<a href=\"[web::cmdurl pricelist]\">price list</a>"</FONT></B> |
| } |
| |
| <I><FONT COLOR="#B22222"># do the command dispatching |
| </FONT></I><I><FONT COLOR="#B22222"># this will switch into "pricelist" or "default" depending on |
| </FONT></I><I><FONT COLOR="#B22222"># the query_string |
| </FONT></I>web::dispatch |
| </PRE> |
| <HR> |
| <ADDRESS>Generated by <A HREF="http://www.iki.fi/~mtr/genscript/">GNU enscript 1.6.3</A>.</ADDRESS> |
| </BODY> |
| </HTML> |