Contents SAS/IntrNet 1.2: Application Dispatcher Previous Next
 

Creating Dispatcher Applications - Graphics Output

This application illustrates how to produce graphics output using the Application Dispatcher. It requires that you have Release 6.12 of SAS/GRAPH software licensed and installed.


The HTML Page

The HTML page for this sample application provides the bare minimum of information. To keep the program code simple, no variables were used other than the _SERVICE, _PROGRAM, and _DEBUG Dispatcher variables. Because none of these values dynamically change the program code, every invocation of this application will produce the same graphic. The focus here is a simple "how to" explanation of creating graphics.

The HTML code for this application is contained in the the Broker package sample directory in a file named grphics.html. The code produces a form that looks like this:

graphics output

For more detailed information on creating the input component of a Dispatcher application, see Input Component Details.


The Dispatcher Program

As in all Dispatcher programs, the first output that must be produced is a valid Content-type header. Because this program uses a GIF graphics driver, the content type is image/gif. A DATA step is used to write out the header. Then some graphics options are set, the graphics procedure is invoked with a GIF driver, and the output is directed to the special _WEBOUT fileref. Here is the complete code for this Dispatcher program.

data _null_;
  file _webout;
  put 'Content-type: image/gif';
  put;
run;


goptions gsfname=_webout gsfmode=replace dev=gif733;

proc gchart data=sashelp.retail;
  hbar year/sumvar=sales;
    pattern v=s;
  Title h=2 c=red 'Chart of Retail Data';
run;
quit;

The resulting graphic is a horizontal bar chart of the sashelp.retail data set. The gsfname option directs the SAS/GRAPH procedure to write the image output to the special fileref and thus back to the Web browser. Notice the gsfmode=replace option. This is very important. You may be tempted to use a mode of append because you have already written to header in the previous DATA step. Do not do that. A gsfmode of replace must always be used, otherwise the procedure may skip the output of some critical GIF initialization information. Do not worry about overwriting data already sent to _WEBOUT. That is impossible. Because the Application Dispatcher uses TCP/IP sockets to flow the data between the Web browser and your program, the _WEBOUT fileref is always appending. There is no concept of replacing what has been previously written. This is similar to how standard output and pipes behave.

Further detail about the program component is available in Dispatcher Program Details.


Contents SAS/IntrNet 1.2: Application Dispatcher Previous Next