SAS/IntrNet 1.2: Application Dispatcher |
Dispatcher Program Details
Types of ProgramsThere are four types of Dispatcher programs. They are
Each of the programs must be stored in a Dispatcher program library. SAS programs are stored in external files and must have a _program=library.program.sas Source programs are stored in SAS catalog entries ending in _program=library.catalog.program.source SCL programs are stored in SAS catalog entries ending in _program=library.catalog.program.scl Macro programs are stored in SAS catalog entries ending in _program=library.catalog.program.macro SAS software automatically creates stored compiled macros in a catalog named Program LibrariesProgram libraries are segregated areas where Dispatcher programs are stored. They are special because they are the only locations from which the Dispatcher is allowed to execute programs. The Application Server control file In preproduction releases of the Application Dispatcher, it was possible to submit a libname statement in open SAS code before invoking the server and it would define a program library. This feature has been disabled. Now all program libraries must be defined in the server autoexec file ( Dispatcher programs stored in Data LibrariesData created or used by Dispatcher programs should not be stored in program libraries. It is a security risk to store programs in the same location as their data. The suggested method for access data from a Dispatcher program is to issue a libname or filename statement in the Dispatcher program code. After the program has completed, the Application Server will clear any libnames or filenames that the program has left assigned. Sometimes there may be the need to have certain libnames or filenames permanently assigned for the duration of the server session. Perhaps a library that contains employee data is accessed by many separate applications. It would be convenient if each application did not have to issue the libname statement. This is the purpose of the Accessing Name/Value Pair DataThe name/value pair data provided by the HTML form are sent to the Dispatcher program and made available as macro variables. The Dispatcher creates these variables, assigns their values, and clears their values after the program has completed. The name/value pair data are also supplied in an SCL list to SCL Dispatcher programs. Application developers must write their Dispatcher program to accept the proper macro variable names. The macro variable values can be obtained by direct reference (for example,
For example, if the HTML name/value pair for a text entry field is color/blue, all of the following store the value blue in the DATA step variable
We recommend that you do not use the first method because it is a security risk. The second method is slightly more secure but also a potential problem. If you intend to use the values in a DATA step, the SYMGET technique is the safest because any special characters contained in the value will not be "seen" by the SAS syntax scanner. Using a reference like Because all macro variables are a character data type, some extra processing is required in DATA step code if the value will be stored in a numeric variable:
If the Dispatcher program is written in SCL, you have another option for accepting the variable values. An SCL list is passed to each Dispatcher program written in SCL. Therefore, each SCL program must contain the following code statement or it will fail when the Application Server invokes it: entry inputlist 8; The input list contains named character items that correspond to the macro variables created. If your program is written in SCL, you can use either the input list or macro variables. To access the same name/value pair as above, a statement like this can be used: color=getnitemc(inputlist,'COLOR',1,1,''); As with the macro variables, this SCL list is cleaned up by the Application Server when the Dispatcher program completes. The Dispatcher automatically creates several variables based on the program request and various information in the Broker configuration file. These automatic variables are available to your program as macro variables and SCL list items. For a complete list of these automatic variables, see the sections Common Environment Variables and Special Dispatcher Fields under Dispatcher Reference. Producing OutputAll output created by Dispatcher programs must contain an abbreviated HTTP header. This header is everything from the beginning of the output up to the first null line. Here is some example output, including the header: Content-type: text/html Pragma: no-cache <HTML> <HEAD><TITLE>Application Server Administrative Program</TITLE></HEAD> <BODY> <H1>Administrative Program</H1> <P>The application server has been shutdown.</P> <HR> </BODY> </HTML> In this example, the HTTP header contains two lines. The minimal requirements for Dispatcher output are that the header contain put ; This, however, is incorrect put " "; because it produces a line containing one blank followed by carriage control. A line with one blank is not a null line and will not be recognized as terminating the header. The output that follows the HTTP header depends upon the content type. If No matter whether the program output is plain text, binary graphics, HTML code, or any other content type, all output intended for the Web browser should be sent to the fileref The HTML Formatting Tools will likely be used for the bulk of any Dispatcher program output. There are some important guidelines to follow when using the Formatting Tools in a Dispatcher program.
The Application Dispatcher is a very flexible programming environment because it provides procedures and tools that automatically generate output, but it also allows exact control of the output. Many SAS programmers have encountered the situation where they want to generate completely custom output. This is often done by using the DATA step and PUT statements. The Dispatcher technology supports PUT statement reporting and allows you to supplement such reports with powerful procedures and Formatting Tools. DebuggingThere are three techniques for debugging Dispatcher programs:
Returning the log to the browserPassing a name/value pair of DATA step debuggerTo use the DATA step debugger, you must start the Application Server in full-screen mode, and you must be working on the computer where SAS software will display the debugger windows. At the server startup, the data mylib.mydata/debug; When the server executes the program, the DATA step debugger windows will pop up and pause, waiting for you to step through the code. SCL debuggerTo use the SCL debugger, you must start the Application Server with the For more information on Application Server invocation options, see Server Invocation Parameters. |
SAS/IntrNet 1.2: Application Dispatcher |