Skip to main content development
   toolset
 
  Easy400   |       iSeries home
Public-Source
 
Introduction
Tutorial
Examples
FAQ
Index
Download
 
 

 
2.2.2 - Loading the external HTML


The external HTML can reside on:

  • A physical file source member.
    In this case the source physical file must be named HTMLSRC and have record length 240. After having being created, the source physical file can be renamed. The important factor is that the name of the record format is HTMLSRC.
  • An IFS stream file.
    In this case, it may be helpful creating the stream file with code page 819 (pure ASCII), the same that would be used when creating it from a PC.
    IFS stream files are loaded with a slightly better performance than source physical file members.

As the files containing the external HTML are loaded by the CGI (via service program procedures), they do not need to be mentioned in the HTTP directives (only files accessed directly from the HTTP server need to be mentioned in the HTTP directives).

There are three procedures for loading the external HTML into memory. One is related to external HTML residing on a source physical file member. The other two perform the loading of HTML stream files.

All these procedures optionally allow to specify:

  • the section start delimiter
  • the section end delimiter
  • the output variable start delimiter
  • the output variable end delimiter

  1.  QGetHtml 
    Use this procedure to load an external HTML residing on a source file member.
    The following parameters are passed:
    1. source file name (char 10)
    2. library name (char 10)
    3. source member name (char 10)
    4. (optional) section start delimiter (char 20)
    5. (optional) section end delimiter (char 20)
    6. (optional) output variable start delimiter (char 20)
    7. (optional) output variable end delimiter (char 20)

    Example of loading the external HTML from source file member
    cgicbldev2/htmlexampl hello
    (in this HTML default delimiters are used both for sections and output variables):
                    ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                  ...         ...         ...
              * Variables to load external HTML
                   05     fn                  PIC  X(10) VALUE 'HTMLEXAMPL'.
                   05     lib                 PIC  X(10) VALUE 'CGICBLDEV2'.
                   05     mbr                 PIC  X(10) VALUE 'HELLO'.
                ...         ...         ...
              * Load the external HTML
                   call 'QGETHTML' using fn lib mbr.

    Example of loading the external HTML from source file member
    cgicbldev2/htmlexampl hello1
    (in this HTML section start delimiter "<as400>" is used instead of the standard one "/$"):
                    ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                  ...         ...         ...
              * Variables to load external HTML
                   05     fn                  PIC  X(10) VALUE 'HTMLEXAMPL'.
                   05     lib                 PIC  X(10) VALUE 'CGICBLDEV2'.
                   05     mbr                 PIC  X(10) VALUE 'HELLO'.
                   05     sctStrDlm           PIC  X(20) VALUE '<as400>'.
                ...         ...         ...
              * Load the external HTML
                   call 'QGETHTML' using fn lib mbr sctStrDlm.

    For an example of using procedure QGETHTML, see the COBOL source of CGI program LISTCTR.

  2.  QGetHtmlIFS 
    Use this procedure to load an external HTML residing on an IFS stream file.
    The following parameters are passed:
    1. Path and name of the stream file (char 1024)
    2. (optional) section start delimiter (char 20)
    3. (optional) section end delimiter (char 20)
    4. (optional) output variable start delimiter (char 20)
    5. (optional) output variable end delimiter (char 20)

    Example of loading the external HTML from stream file
    /cgicbldev2/html/listctrifs.txt
    (in this HTML section start delimiter "<as400>" is used instead of the standard one "/$"):
                    ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                  ...         ...         ...
              * Variables to load external HTML via QgetHtmlIFS
                   05     IFSFile             PIC  X(1024).
                   05     sctStrDlm           PIC  X(20) VALUE '<as400>'.
                ...         ...         ...
              * Load the external HTML
                  move '/cgicbldev2/html/listctrifs.txt' to IFSFile.
                  call 'QGETHTMLIFS' using
                                     IFSFile
                                     sctStrDlm.

    For an example of using procedure QGETHTMLIFS, see the COBOL source of CGI program LISTCTRIFS.

  3.  QGetHtmlIFSMult 
    There might be cases where some sections of HTML are common to several CGI programs. In such cases, the ability to load in a single shot more than a single stream file would solve the problem.
    The following parameters are passed to procedure QGetHtmlIfsMUlt:
    1. Paths and names of the stream files to be loaded (char 32767)
    2. (optional) section start delimiter (char 20)
    3. (optional) section end delimiter (char 20)
    4. (optional) output variable start delimiter (char 20)
    5. (optional) output variable end delimiter (char 20)
    Note 1. All the stream files loaded must use the same section delimiters and the same output variable delimiters.
    Note 2. Section names must be unique across all the stream files loaded.

    Example of loading the external HTML from stream files
    /cgicbldev2/html/part1.txt and
    /cgicbldev2/html/part2.txt
    (in these stream files section start delimiter "<as400>" is used instead of the standard one "/$"):
                    ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                  ...         ...         ...
              * Variables to load external HTML via QgetHtmlIFSMult
                   05     IFSFiles            PIC  X(32767).
                   05     sctStrDlm           PIC  X(20) VALUE '<as400>'.
                ...         ...         ...
              * Load the external HTML
                  move '/cgicbldev2/html/part1.txt /cgicbldev2/html/part2.txt'
                       to IFSFiles.
                  call 'QGETHTMLIFSMULT' using
                                         IFSFiles
                                         sctStrDlm.

    For an example of using procedure QGETHTMLIFSMULT, see the COBOL source of CGI program LISTCTRIFM.

 Stream file access 
Special attention should be payed to the authorities of the stream files to be loaded. The user profile performing the loading is usually the one used by the HTTP server to run CGI, that is QTMHHTP1.
You must make sure that this user profile (or the *PUBLIC) can read the stream files.

In the following two examples, user profile QTMHHTP1 is authorized to read the stream file (owned by user profile QPGMR):
Data --Object Authorities--
User Authority Exist  Mgt  Alter  Ref 
*PUBLIC  *RX
QPGMR *RWX X X X X

or
Data --Object Authorities--
User Authority Exist  Mgt  Alter  Ref 
*PUBLIC  *EXCLUDE
QPGMR *RWX X X X X
QTMHHTP1 *RX



    Contact