![]() | ![]() | ![]() |
The classic Hello World! program illustrates how to use Application Dispatcher to create a simple application. This sample is divided into two parts:
The HTML code for this application is installed along with the Application Broker in the following default location:
http://yourserver/sasweb/IntrNet9/dispatch/webhello.html
The input component for this and most Application Dispatcher applications is an HTML page that contains an HTML form. The form for this program consists of a single button that runs the program component of the application when selected. The <FORM> tag begins a form and the </FORM> tag ends it. Tags that create the pieces of the form are inserted between these begin and end form tags.
Use the ACTION attribute inside the <FORM> tag to instruct the Web browser what action to take when a user completes and submits the form. For Application Dispatcher applications, the action is the URL for the Application Broker. Here is an example:
<FORM ACTION="/cgi-bin/broker">
form components go here
</FORM>
At this point, the form does not contain any input fields or buttons. For this application, a single button is added to the form by inserting an <INPUT> tag in the HTML code. A type of SUBMIT
and a value of Say Hello are supplied as parameters to the <INPUT> tag. The type SUBMIT causes the field to display as a button, and the value sets the text that is displayed on the button. Here is an example:
<FORM ACTION="/cgi-bin/broker">
<INPUT TYPE="SUBMIT" VALUE="Say Hello">
</FORM>
This is enough to create a visible, functional HTML form, but it is not enough to make it work with the Application Dispatcher. The Application Dispatcher has input requirements beyond those of the basic HTML form. Two special variables must be supplied when the form is submitted, _SERVICE and _PROGRAM.
The _SERVICE field is one of the required fields in the HTML form for an Application Dispatcher application. The value must match the name of a service defined in your Application Broker configuration file.
Most often, this information will be supplied in a hidden field, as shown in the following example:
<INPUT TYPE="hidden" NAME=_service VALUE="default">
Specifying the type as hidden prevents the Web browser from showing the field to the user.
The _PROGRAM field is also required. Its value indicates the name of the Application Dispatcher program that the Application Server should look for and run. The program name for this application is sample.webhello.sas. Like _SERVICE, this field is most often supplied as a hidden field, as follows:
<INPUT TYPE="hidden" NAME="_program" VALUE="sample.webhello.sas">
This completes the basic HTML form. You can find the HTML code in the Application Broker package sample directory in a file named webhello.html. The following code is the complete HTML code for the input component of this application:
<HTML>
<HEAD>
<TITLE>Hello World!</TITLE>
</HEAD>
<BODY>
<H2>Hello World Sample Application</H2>
<HR>
<FORM ACTION="/cgi-bin/broker">
<INPUT TYPE="HIDDEN" NAME="_PROGRAM" VALUE="sample.webhello.sas">
<INPUT TYPE="HIDDEN" NAME="_SERVICE" VALUE="default">
<INPUT TYPE="SUBMIT" VALUE="Say Hello">
</FORM>
</BODY>
</HTML>
The previous code produces a form that looks like the following:
When you click Submit on the HTML form, the Web browser passes the form data to the Application Broker. The Application Broker then passes the data to an Application Server, which runs the Application Dispatcher program. For an overview of this process, see How the Application Dispatcher Works.
The source code for this application has a simple function: to make the words Hello World! appear in the user's Web browser. Because the program is run inside a SAS session, it must be written in Base SAS, a macro, or SCL code. The following program is written in Base SAS, specifically the DATA step:
data _null_;
file _webout;
put 'Content-type: text/html';
put ;
put '<HTML>';
put '<HEAD><TITLE>Hello World!</TITLE></HEAD>';
put '<BODY>';
put '<H1>Hello World!</H1>';
put '</BODY>';
put '</HTML>';
run;
A DATA _NULL_ step references a fileref of _WEBOUT. This fileref is predefined by the Application Server. You can think of writing to this fileref as writing to the Web browser. Because the Application Dispatcher operates within the Common Gateway Interface (CGI), the first output a program produces must be an abbreviated HTTP header. In this program, the header is the content-type declaration followed by a null record. Because the content was declared to be text or HTML, the program follows the header with the source code for the HTML page that it will produce.
The Application Broker receives this output before the Web browser and checks for a correct header. It then goes through the following steps:
Hello World!
This sample application was hardcoded for ease of use. However, using more input fields on the form will provide variables to the Application Dispatcher program that can then produce dynamic output.
The complete source code for this sample is installed in the Application Server sample library in a file named webhello.sas.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
| Type: | Sample |
| Topic: | Software Components ==> Application Dispatcher |
| Date Modified: | 2007-09-30 18:45:56 |
| Date Created: | 2006-07-12 13:30:21 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | SAS/IntrNet | All | n/a | n/a |


