-
AS/400e HTTP Server for AS/400 Web Programming Guide GC41-5435-04
-
-
AS/400e HTTP Server for AS/400 Web Programming Guide GC41-5435-04
-
Note Before using this information and the product it supports, be sure to read the general information under “Chapter 11. Notices” on page 145. Fifth Edition (May 2000) This edition applies to the IBM HTTP Server for AS/400 licensed program (Program 5769-DG1), Version 4 Release 5 Modification 0 and to all subsequent releases and modifications until otherwise indicated in new editions. This edition applies only to reduced instruction set computer (RISC) systems. This edition replaces GC41-5435-03.
-
Contents About HTTP Server for AS/400 Web Programming Guide (GC41-5435) . . . . v Conventions in this book . . . . . . . . . . v AS/400 Operations Navigator . . . . . . . . v Installing Operations Navigator . . . . . . . vi Prerequisite and related information . . . . . . vi How to send your comments . . . . . . . . vi Chapter 1. Writing Common Gateway Interface Programs . . . . . . . . . . 1 Overview of the CGI . . . . . . . . . CGI and Dynamic Documents . . . . . Uses for CGI . . . . . . . . . . .
-
Overview of Persistent CGI . . . . . Named Activation Groups . . . . Accept-HTSession CGI Header . . . HTTimeout CGI Header . . . . . Considerations for using Persistent CGI Programs . . . . . . . . . . Persistent CGI Program Example . . . . . . . . . . . . . . . . . . 81 81 81 82 . . . . . . . 82 . 83 Chapter 5. Enabling your AS/400 to run CGI programs. . . . . . . . . . . . 85 How to enable the server to run CGI programs Using directives for security and access control The default fail rule . .
-
About HTTP Server for AS/400 Web Programming Guide (GC41-5435) The web is an interactive medium. For example, it allows users to use search utilities to locate information on a topic, give feedback to a company about its products, and more. The IBM HTTP Server software does not perform these tasks. They are performed by external programs using information passed to them by the server.
-
recommends that you use AS/400 Operations Navigator, which has online help to guide you. While this interface is being developed, you may still need to use an emulator such as PC5250 to do some of your tasks. Installing Operations Navigator To use AS/400 Operations Navigator, you must have Client Access installed on your Windows PC. For help in connecting your Windows PC to your AS/400 system, consult Client Access Express for Windows - Setup, SC41-5507-01.
-
– RCHCLERK@us.ibm.com Be sure to include the following: v The name of the book. v The publication number of the book. v The page number or topic to which your comment applies.
-
viii Web Programming Guide V4R5
-
Chapter 1. Writing Common Gateway Interface Programs Overview of the CGI . . . . . . . . . . . 1 CGI and Dynamic Documents . . . . . . . 2 Uses for CGI . . . . . . . . . . . . . 3 The CGI process . . . . . . . . . . . . . 3 Overview . . . . . . . . . . . . . . 3 Sending Information to the Server . . . . . . 5 Data Conversions on CGI Input and Output . . . 5 CGI Input Conversion Modes. . . . . . . 6 DBCS Considerations . . . . . . . . . 7 CGI Output Conversion Modes . . . . . .
-
The functions and tasks that CGI programs can perform range from the simple to the very advanced. In general, we call those that perform the simple tasks CGI scripts because you do not compile them. We often call those that perform complex tasks gateway programs. In this manual, we refer to both types as CGI programs. Given the wide choice of languages and the variety of functions, the possible uses for CGI programs seem almost endless. How you use them is up to you.
-
Uses for CGI HTML allows you to access resources on the Internet by using other protocols that are specified in the URL. Examples of such protocols are mailto, ftp, and news. If you code a link with mailto that is followed by an e-mail address, the link will result in a generic mail form.
-
The following HTML form illustrates the various types of fields: Note: The CGIXMP.EXE program referred to in this sample is just an example; it is not shipped with the server product.
CGIXMP Test Case CGI Sample Test Case
Fill in the following fields and press APPLY. The values you enter will be read by the CGIXMP.EXE program and displayed in a simple HTML form which is generated dynamically by the program.
-
Enter Password
Hidden Field
Sending Information to the Server When you fill out a form, the web browser sends the request to the server in a format that is described as URL-encoded.
-
back to the browser. You must provide data to a CGI program through environment variables and standard-input (stdin). HTTP and HTML specifications allow you to tag text data with a character set (charset parameter on the Content-Type header). However, this practice is not widely in use today (although technically required for HTTP1.0/1.1 compliance). According to this specification, text data that is not tagged can be assumed to be in the default character set ISO-8859-1 (US-ASCII).
-
In this mode, the server will convert everything into the EBCDIC CCSID of the job. The server checks the Entity bodies for a charset tag. If found, the server will convert the corresponding ASCII CCSID to the EBCDIC CCSID of the job. If the server does not find a charset tag, it uses the value of the DefaultNetCCSID configuration directive as the conversion CCSID. In addition, the system converts escaped octets from ASCII to EBCDIC, eliminating the need to perform this conversion in the CGI program.
-
Using the EBCDIC_JCD mode: The EBCDIC_JCD mode determines what character set is being used by the browser for a given request. This mode is also used to automatically adjust the ASCII/EBCDIC code conversions used by the web server as the request is processed. After auto detection, the %%EBCDIC_JCD%% mode converts the stdin and QUERY_STRING data from the detected network CCSID into the correct EBCDIC CCSID for Japanese. The default conversions configured for the server instance are overridden.
-
Notes: 1. If startup NetCCSID is 932 or 942, detected network, Shift JIS’s CCSID is the same as startup NetCCSID. Otherwise, Shift JIS’s CCSID is 943. Startup NetCCSID ---------------932 942 943 5052 5054 5050 Shift JIS (JCD detected CCSID) -----------------------------932 942 943 943 943 943 2. Netscape Navigator 3.x sends the alphanumeric characters by using JIS X 0201 Roman escape sequence (CCSID 5052) for ISO-2022-JP. Netscape Communicator 4.
-
%%MIXED%% In this mode HTTP header output is in CCSID 37. However, the escape sequence must be the EBCDIC representative of the ASCII code point for the 2 characters following the ″%″ in the escape sequence. An example of a HTTP header that may contain escape sequences is the Location header. %%EBCDIC%% In this mode HTTP header output is in CCSID 37. However, the escape sequence must be the EBCDIC representative of the EBCDIC code point for the 2 characters following the ″%″ in the escape sequence.
-
Table 2. Conversion action and charset tag generation for text in CGI Stdout. (continued) CGI Stdout CCSID/Charset in HTTP header Conversion action None (%%MIXED%% or %%MIXED/MIXED%%) Default Conversion - FsCCSID to NetCCSID Invalid CGI error 500 generated by server Server reply charset tag None (compatibility mode) The server also sets an environment variable CGI_OUTPUT_MODE to reflect the setting for the CGI output mode.
-
How CGI Programs Work Most CGI programs include the following three stages: v Parsing CGI programs v Data manipulation within a CGI program v Response generation by a CGI program Parsing Parsing is the first stage of a CGI program. In this stage, the program takes the data from QUERY_STRING environment variable, command line arguments using argv() or standard input. When the method is GET, the system reads the data from the QUERY_STRING environment variable or command line arguments by using argv().
-
With a search, the response might be the URLs of all the documents that met the search value. With a request that results in e-mail, the response might be a message that confirms that the system actually sent the e-mail. Environment variables Before you begin writing your CGI program, you need to understand the format in which the server will pass the data. The server receives the URL-encoded information and, depending on the type of request, passes the information to the CGI program.
-
GATEWAY_INTERFACE Contains the version of CGI that the server is using. For example: CGI/1.1 HTTP_ACCEPT Contains the list of MIME types the browser accepts. For example: text/html HTTP_USER_AGENT Contains the name of your browser (web client). It includes the name and version of the browser, requests that are made through a proxy, and other information. For example: Netscape Navigator dll /v3.0 IBM_CCSID_VALUE The CCSID under which the current server job is running.
-
SCRIPT_NAME A virtual path to the program being run. Use this for self-referring URLs. SERVER_NAME Contains the server host name or IP address of the server. For example: www.ibm.com SERVER_PORT Contains the port number to which the client request was sent. For example: 80 SERVER_PROTOCOL Contains the name and version of the information protocol that is used to make the request. For example: HTTP/1.
-
HTTPS_CLIENT_CERT_COMMON_NAME The Common Name from the client certificate’s distinguished name. For example: John Smith HTTPS_CLIENT_CERT_ISSUER_COMMON_NAME The Common Name of the Certificate Authority that issued the client’s certificate. For example: Digital ID HTTPS_CLIENT_CERT_ISSUER_COUNTRY The Country code of the Certificate Authority that issued the client’s certificate.
-
HTTPS_CLIENT_CERT_STATE_OR_PROVINCE The State or Province from the client certificate’s distinguished name. For example: Minnesota HTTPS_KEYSIZE Returns the number of bits in the session key that is established by SSL after a completed exchange of signals to set up communications between two modems. This value is blank if HTTPS=OFF. For example: 512 Examples of key sizes are Export {40} or {128}.
-
*NEW- The name for this activation group is selected by ILE and will always be unique. System-named activation groups are always deleted when the high level language returns. *CALLER - Specifying *CALLER causes the ILE program or service program to be activated within the activation group of the calling program. A new activation group is never created with this attribute. *NEW is the standard behavior that can be expected on other systems such as UNIX®. Notes: 1.
-
information that was written to stdout. This will cause the web browser to display a ″Document Contains No Data″ error message. Another application could run again in the same activation group that properly erased stdout. In this instance, the data that has been buffered from previous calls would be sent. #include void main(void) { /***************************************************/ /* Write header information.
-
v The heap storage allocated using malloc is not being freed. Over time, a memory leak error like this could use significant amounts of memory. This is a common application error that only surfaces when the application is not running in a *NEW activation group. /*************************************************************************/ /* */ /* CGI Example program.
-
{ char* char* int int FILE* stdinBuffer; contentLength; numBytes; bytesRead; pStdin; /**********************************************************************/ /* Write the header. */ /**********************************************************************/ printf("Content-type: text/html\n\n"); /**********************************************************************/ /* Get the length of data on stdin.
-
22 Web Programming Guide V4R5
-
Chapter 2. Application Programming Interfaces APIs for CGI applications . . . . . . . . . Get Environment Variable (QtmhGetEnv) API . . Required parameter group . . . . . . . Error messages . . . . . . . . . . . Put Environment Variable (QtmhPutEnv) API . . Required parameter group . . . . . . . Error messages . . . . . . . . . . . Read from Stdin (QtmhRdStin) API . . . . . Required parameter group . . . . . . . Error Messages . . . . . . . . . . . Write to Stdout (QtmhWrStout) API . . . . .
-
Delete a Server Instance (QzhbDeleteInstance) API . . . . . . . . . . . . . . . Authorities and locks . . . . . . . . Required parameter group . . . . . . Error messages . . . . . . . . . . Group file APIs . . . . . . . . . . . . Create a new Group File (QzhbCreateGroupList) API . . . . . . . . . . . . . . . Authorities and locks . . . . . . . . Required parameter group . . . . . . Error messages . . . . . . . . . . Read a Group File into Memory (QzhbOpenGroupList) API . . . . . . . Authorities and locks .
-
Get Environment Variable (QtmhGetEnv) API Parameters Required Parameter Group: 1 2 3 4 5 6 Receiver variable Length of receiver variable Length of response Request variable Length of request variable Error Code Output Input Output Input Input I/O Char(*) Binary(4) Binary(4) Char(*) Binary(4) CHAR(*) The QtmhGetEnv API allows you to get the value set by the server for a particular HTTP environment variable.
-
The structure in which to return error information. For the format of the structure and for details on how to process API errors, see the programming topic in the AS/400 Information Center. Error messages CPF24B4 E Severe Error while addressing parameter list. CPF3C17 E Error occurred with input data parameter. CPF3C19 E Error occurred with receiver variable specified. CPF3CF1 E Error code parameter not valid.
-
The structure in which to return error information. For the format of the structure and for details on how to process API errors, see the programming topic in the AS/400 Information Center. Error messages CPF24B4 E Severe Error while addressing parameter list. CPF3021 E The value specified for the argument is not correct. CPF3C17 E Error occurred with input data parameter. CPF3CF1 E Error code parameter not valid. CPF3408 E The address used for an argument is not correct.
-
The program reads all of the data in a single request. This is because the API treats each request as a request for data starting at its beginning. The API handles each request as if it was the only request. The length of the data returned by QtmhRdStin includes all the data from stdin. This includes line-formatting characters that are normally a part of the POST data as defined by the CGI specification. Note that the format of this data is different depending on the CGI input mode being used.
-
Write to Stdout (QtmhWrStout) API Parameters Required Parameter Group: 1 Data variable 2 Length of data variable 3 Error Code Input Input I/O Char(*) Binary(4) Char(*) The QtmhWrStout API provides the ability for CGI programs that are written in languages other than C to write to stdout. Required parameter group Data variable Input:CHAR(*) The input variable containing the data to write to stdout.
-
Convert to DB (QtmhCvtDB) API Parameters Required Parameter Group: 1 2 3 4 5 6 7 8 Qualified database file name Input string Length of input string Response variable Length of response variable Length of response available Response code Error Code Input Input Input Output Input Output Output I/O Char(20) Char(*) Binary(4) Char(*) Binary(4) Binary(4) Binary(4) Char(*) The QtmhCvtDB API provides an interface for CGI programs to parse CGI input, defined as a series of keywords and their values, into a buff
-
3. Input to Binary fields is converted to integer. The DDS file specification must declare zero decimal positions (for example, “xB 0”, where x is 1-9). 4. ILE C converts hex DDS field data to character fields. Since the input stream to QtmhCvtDB() is a text string, the “hex” data would be converted from text to character fields. Therefore, using the A (Alphanumeric) field type to obtain the same conversion.
-
-1 The database file contains definitions for structure fields for which the CGI input has no corresponding keyword. -2 The CGI input contains one or more keywords for which the database file contains no corresponding field. -3 A combination of the condition for response codes -1 and -2 has been detected. -4 An error occurred while converting the CGI input string to the DDS defined data types. The data may or may not be usable.
-
Parameters Required Parameter Group: 1 2 3 4 5 6 Command string Output format Target Buffer Length of Target Buffer Length of response Error Code Input Input Output Input Output I/O Char(*) Char(8) Char(*) Binary(4) Binary(4) CHAR(*) Required parameter group Command string Input:CHAR(20) The command string is a null ended string for flags and modifiers. At least one space must separate each flag. There is a one-character equivalent for each flag.
-
-p[refix] prefix Used with -POST and -form to specify the prefix to use when creating environment variable names. The default is ″FORM_″. -c[ount] Used with -keywords, -form, and -value, returns a count of items in the target buffer that is related to these flags: -keywords Returns the number of keywords. -form Returns the number of unique fields (multiple values are counted as one) -value field-name Returns the number of values for field-name. If there is no field that is named field-name, the output is 0.
-
Target Buffer OUTPUT:CHAR(*) This is output buffer that contains the information requested by the command string (if any). Length of Target Buffer INPUT:BINARY(4) The length of the target buffer provided to receive the API output. Length of Response OUTPUT:BINARY(4) The actual length of the information returned in the target buffer. Error Code I/O:CHAR(*) The structure in which to return error information.
-
Offset to first variable entry The offset to the first variable entry returned. The offset is from the beginning of the structure. If no entries are returned, the offset is set to zero. Number of variable entries returned The number of variable entries returned. If the target buffer is not large enough to hold the information, this number contains only the number of variables actually returned. Reserved This field is ignored. Length of variable entry The length of this variable entry.
-
Command string INPUT:CHAR(*) The command string is a null ended string of flags and modifiers. Each flag must be separated by at least one space. The following flags are supported: -nodate Does not return the Date: header to the browser. -noel Does not return a blank line after headers. This is useful if you want other MIME headers after the initial header lines. -status nnn Returns full HTTP response with status code nnn, instead of only a set of HTTP headers.
-
Error messages CPF24B4 E Severe Error while addressing parameter list. CPF3C17 E Error occurred with input data parameter. CPF3CF1 E Error code parameter not valid. Configuration APIs The configuration APIs are in *SRVPGM QZHBCONF in library QHTTPSVR. ILE C programs must include header file QHTTPSVR/H(QZHBCONF).
-
Required parameter group Name of Configuration INPUT; CHAR(10) The name of the configuration from where to retrieve the information. The URL INPUT; CHAR(*) The URL to convert into a physical resource. Length of the URL INPUT; BINARY(4) The length of the URL. Path to physical resource OUTPUT; CHAR(*) The fully qualified path to the physical resource the web server would serve as a result of a request of this URL.
-
The actual length of the QUERY_STRING. When the API is unable to determine QUERY_STRING, this value will be set to zero. When the size required for QUERY_STRING is larger than the length of the space provided, the actual space required is returned. Error Code I/O; CHAR(*) The structure in which to return error information. For the format of the structure and for details on how to process API errors, see the programming topic in the AS/400 Information Center.
-
Name of the directive INPUT; CHAR(*) The name of the directive to retrieve. Length of the directive name INPUT; BINARY(4) The length of the directive name. Number of values returned OUTPUT; BINARY(4) The number of values returned in the output buffer. This value will be zero if the server finds no matching directives or if there was not enough space available for all the values. Format name INPUT; CHAR(8) The format of the data returned.The possible format names follow: RTVD0100 Retrieve length/value pairs.
-
Error messages CPF3C17 E Error occurred with input data parameter CPF3CF1 E Error code parameter not valid. HTPA104 E Server configuration not found or is unreadable.
-
The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. HTPA001 E Input parameter &1 not valid. CPF9802 E Not authorized to object &2 &3. Create a Configuration (QzhbCreateConfig) API Required Parameter Group: 1 name 2 basedname 3 basedfile 4 basedf_len 5 errcode Threadsafe: Yes Input Input Input Input I/O Char(10) Char(10) Char(8) Binary(4) Char(*) Use the QzhbCreateConfig API to create a new configuration.
-
The length of the basedfile file. A length of 0 means that no basedfile file is passed. If this parameter is greater than 0, basedname cannot also be passed. errcode I/O:CHAR(*) The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. CPFB602 E Cannot open file. HTPA001 E Input parameter &1 not valid. HTPA104 E Server configuration &1 not found or is unreadable. HTPA105 E Unable to update server configuration &1. CPF9802 E Not authorized to object &2 &3.
-
HTPA001 E Input parameter &1 not valid. HTPA104 E Server configuration &1 not found or is unreadable. HTPA105 E Unable to update server configuration &1. CPF9802 E Not authorized to object &2 &3. Read a Configuration File into Memory (QzhbOpenConfig) API Required Parameter Group: 1 name 2 writelock 3 cfg 4 errcode Threadsafe: Yes Input Input Output I/O Char(10) Binary(4) Binary(4) Char(*) Use the QzhbOpenConfig API to read a configuration file into memory.
-
Note: You must specify a writelock of 1, and successfully obtain the object lock, in order to later specify a write argument of 1 on the QzhbCloseConfig API. If you do not have this lock, the QzhbCloseConfig API will not write the contents of the configuration file. cfg OUTPUT:BINARY(4) The handle returned to the loaded configuration file. errcode I/O:CHAR(*) The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. HTPA001 E Input parameter &1 not valid.
-
When 1 is specified in the write parameter, the directives are written to the configuration file before being freed from memory. If a write fails, the memory is not freed, the handle is still valid, and error information is returned. When 0 is specified, the dirrectives are not written, but the object lock is released if it was obtained at QzhbOpenConfig time. Note: In order to specify a write of 1, you must have previously specified a writelock of 1 on the QzhbOpenConfig API.
-
The character string for matching to a directive. Only as many tokens (words delimited by a space) as are provided are matched. Any extra tokens either on the value string or the directive being considered for a match will not be compared. For example a value string of Port 1234 junk will match a directive of Port 1234. To match any directive, including comment lines, pass either a NULL pointer or a string with no tokens on it such as a 0 length string.
-
HTPA107 E Input directive handle in parameter &1 not valid. HTPA108 E Input directive handle in parameter &1 not a main directive. HTPA110 E No matching directive found.
-
value_len INPUT:BINARY(4) The length of the value string. startdir INPUT:BINARY(4) The subdirective handle that specifies where to begin searching for a match. The subdirective immediately following this one is the first one searched. If the startdir parameter is passed as a NULL (omitted), then searching begins at the beginning of the subdirective list for maindir. If the startdir parameter is not NULL, then the maindir parameter can be passed as NULL since the main directive is implied by startdir.
-
HTPA110 E No matching directive found. Return Details of a Main Directive or Subdirective (QzhbGetDirectiveDetail) API Required Parameter Group: 1 cfg 2 dir 3 buf 4 buf_size 5 buf_actlen 6 hassubdirs 7 issubdir 8 errcode Threadsafe: Yes Input Input Output Input Output Output Output I/O Binary(4) Binary(4) Char(*) Binary(4) Binary(4) Binary(4) Binary(4) Char(*) Use the QzhbGetDirectiveDetail API to extract detail information about a main directive or subdirective. Authorities and locks None.
-
issubdir OUTPUT:BINARY(4) The value is set to 1 (true) when dir is a subdirective. The value is set to 0 (false) when dir is a main directive. errcode I/O:CHAR(*) The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. CPF3C1D E Input variable length in parameter &1 not valid. HTPA001 E Input parameter &1 not valid. HTPA106 E Input configuration handle not valid. HTPA107 E Input directive handle in parameter &1 not valid.
-
value_len INPUT:BINARY(4) The length of the value string. The length must be greater than or equal to 1. position INPUT:BINARY(4) The number indicating the insertion position for the new directive. See Table 3 for more information. reldir INPUT:BINARY(4) The handle to a main directive or subdirective, or a NULL (omitted). See Table 3 for more information. newdir OUTPUT:BINARY(4) The handle of the newly added main directive or subdirective.
-
Table 3. Using the reldir and position parameters. (continued) reldir value Subdirective Position 0 (Before) Position 1 (After) Inserted as a subdirective directly proceeding reldir. Inserted as a subdirective directly following reldir. Position 2 (At front) Position 3 (At end) Position 4 (Automatic) Not valid Not valid Not valid Error messages CPF3CF1 E Error code parameter not valid. CPF3C1D E Input variable length in parameter &1 not valid. HTPA001 E Input parameter &1 not valid.
-
The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. HTPA001 E Input parameter &1 not valid. HTPA106 E Input configuration handle not valid. HTPA107 E Input directive handle in parameter &1 not valid.
-
Error messages CPF3CF1 E Error code parameter not valid. CPF3C1D E Input variable length in parameter &1 not valid. HTPA001 E Input parameter &1 not valid. HTPA106 E Input configuration handle not valid. HTPA107 E Input directive handle in parameter &1 not valid. Server instance APIs The server instance APIs are in *SRVPGM QZHBCONF in library QHTTPSVR. ILE C programs must include header file QHTTPSVR/H(QZHBCONF).
-
The buffer where the instance names are placed. Specify a buffer name up to 10 characters (padded with blanks) as necessary. buf_size INPUT:BINARY(4) The size of the buffer in bytes. format INPUT:CHAR(8) The format of the data returned. The possible format names follow: INSN0100 buf_actlen OUTPUT:BINARY(4) The length of all the instance names. Any data beyond the size specified in the buf_size value is truncated by the system. count OUTPUT:BINARY(4) The total number of instance names.
-
HTPA001 E Input parameter &1 not valid CPF9802 E Not authorized to object &2 in &3. Look up Server Instance Data (QzhbGetInstanceData) API Required Parameter Group: 1 name 2 buf 3 buf_size 4 format 5 buf_actlen 6 running 7 errcode Threadsafe: Yes Input Output Input Input Output Output I/O Char(10) Void Binary(4) Char(8) Binary(4) Binary(4) Char(*) Use the QzhbGetInstanceData API to get detailed data about a specific server instance.
-
The number of bytes available for instance data. For the INSD0100 format, the buf_actlen value is 1104 bytes. running OUTPUT:BINARY(4) Indicates if the server instance is running. If the instance is running, the running parameter is set to 1. If the instance is not running, the running parameter is set to 0. The running parameter can be omitted. If this value is omitted (null), the running status is not queried by this API, and no performance penalty is incurred for finding this information.
-
Max threads The maximum number of threads to use for this instance. It is an integer from -1 to 999, where 0 means the *CFG value and -1 means *NOMAX (no maximum). CCSID The character set to be used by the instance. It is an integer from 0 to 65533, where 0 means *GLOBAL. Outgoing table name The name of the table object to use as the EBCDIC to ASCII conversion table for outgoing data. It is a 10 character name or *GLOBAL. Outgoing table library The library containing the EBCDIC to ASCII table.
-
3 4 5 Threadsafe: idata_size format errcode Yes Input Input I/O Binary(4) Char(8) Char(*) Use the QzhbChangeInstanceData API to change the start-up data for a specific server instance. This API provides a structure for input, even when not changing values, to all start-up data values to be set for a server instance. This API is typically used following a call to the QzhbGetInstanceData API, and after one or more fields in the structure have been modified.
-
CPF3C1D E Input variable length in parameter &1 not valid. CPF3C21 E Format name &1 not valid. HTPA001 E Input parameter &1 not valid. HTPA101 E Server instance &1 not found or is unreadable. HTPA102 E Unable to update server instance &1. HTPA103 E Value in field &1 of the instance data structure not valid.
-
format INPUT:CHAR(8) The format of the data returned. The possible format names follow: INSD0100 For information about the INSD0100 format, see “INSD0100 Format” on page 59. errcode I/O:CHAR(*) The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. CPF3C1D E Input variable length in parameter &1 not valid. CPF3C21 E Format name &1 not valid. HTPA001 E Input parameter &1 not valid. HTPA102 E Unable to update server instance &1.
-
errcode I/O:CHAR(*) The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. HTPA001 E Input parameter &1 not valid HTPA101 E Server instance &1 not found or is unreadable. HTPA102 E Unable to update server instance &1. CPF9802 E Not authorized to object &2 &3. Group file APIs The group file APIs are in *SRVPGM QZHBCONF in library QHTTPSVR. ILE C programs must include header file QHTTPSVR/H(QZHBCONF).
-
Required parameter group path INPUT:BINARY(4) The path to the group file to be created in the Integrated File System. You can specify an absolute or relative path to the working directory. This path should be in the job CCSID. path_len INPUT:BINARY(4) The length of the path string. grplist OUTPUT:BINARY(4) The variable that receives the integer handle of the newly created empty group list. Subsequent API calls use this handle. errcode I/O:CHAR(*) The structure in which to return error information.
-
v *R authority to the group file for a writelock value of 0 v *RW authority to the group file for a writelock value of 1 Required parameter group path INPUT:BINARY(4) The path to the group file to be created in the Integrated File System. You can specify an absolute or relative path to the working directory. path_len INPUT:BINARY(4) The length of the path string. writelock If the value is 1, the group file is opened for write access with a lock and kept open.
-
Free Group File from Memory (QzhbCloseGroupList) API Required Parameter Group: 1 grplist 2 write 3 errcode Threadsafe: Yes Input Input I/O Binary(4) Binary(4) Char(*) Use the QzhbCloseGroupList API to free the memory of an in-memory copy of a group file. You can optionally write the in-memory version of the group list back to the group file before the memory is freed. Authorities and locks None.
-
Retrieve the next Group in the Group List (QzhbGetNextGroup) API Required Parameter Group: 1 grplist 2 prev_grp 3 grp 4 errcode Threadsafe: Yes Input Input Output I/O Binary(4) Binary(4) Binary(4) Char(*) Use the QzhbGetNextGroup API to retrieve the next group from an in-memory group list. Authorities and locks None. Required parameter group grplist INPUT:BINARY(4) The group list handle returned from a call to the QzhbCreateGroupList or QzhbOpenGroupList API.
-
Locate a named group in a Group List (QzhbFindGroupInList) API Required Parameter Group: 1 grplist 2 group 3 group_len 4 grp 5 errcode Threadsafe: Yes Input Input Input Output I/O Binary(4) Binary(4) Binary(4) Binary(4) Char(*) Use the QzhbFindGroupInList API to search an in-memory group list for a named group. Authorities and locks None. Required parameter group grplist INPUT:BINARY(4) The group list handle returned from a call to the QzhbCreateGroupList or QzhbOpenGroupList API.
-
HTPA206 E Group file &1 not found in group list. Retrieve the Name of a Group (QzhbGetGroupName) API Required Parameter Group: 1 grplist 2 grp 3 buf 4 buf_len 5 buf_actlen 6 errcode Threadsafe: Yes Input Input Output Input Output I/O Binary(4) Binary(4) Char(*) Binary(4) Binary(4) Char(*) Use the QzhbGetGroupName API to retrieve the name of a group using the group handle. Authorities and locks None.
-
CPF3C1D E Input variable length in parameter &1 not valid. HTPA001 E Input parameter &1 not valid. HTPA203 E Input group list handle in parameter &1 not valid. HTPA204 E Input group handle in parameter &1 not valid.
-
Error messages CPF3CF1 E Error code parameter not valid. CPF3C1D E Input variable length in parameter &1 not valid. HTPA001 E Input parameter &1 not valid. HTPA203 E Input group list handle in parameter &1 not valid.
-
Retrieve the next User in the Group (QzhbGetNextUser) API Required Parameter Group: 1 grplist 2 grp 3 prev_usr 5 usr 6 errcode Threadsafe: Yes Input Input Input Output I/O Binary(4) Binary(4) Binary(4) Binary(4) Char(*) Use the QzhbGetNextUser API to retrieve the next user from a group. Authorities and locks None. Required parameter group grplist INPUT:BINARY(4) The group list handle returned from a call to the QzhbCreateGroupList or QzhbOpenGroupList API.
-
HTPA205 E Input user handle in parameter &1 not valid. HTPA207 E User &1 not found in group. Locate a User in a Group (QzhbFindUserInGroup) API Required Parameter Group: 1 grplist 2 grp 3 user 4 user_len 5 usr 6 errcode Threadsafe: Yes Input Input Input Input Output I/O Binary(4) Binary(4) Char(*) Binary(4) Binary(4) Char(*) Use the QzhbFindUserInGroup API to search an in-memory group for a specific user. Authorities and locks None.
-
Error messages CPF3CF1 E Error code parameter not valid. CPF3C1D E Input variable length in parameter &1 not valid. HTPA001 E Input parameter &1 not valid. HTPA203 E Input group list handle in parameter &1 not valid. HTPA204 E Input group handle in parameter &1 not valid. HTPA207 E User &1 not found in group.
-
buf OUTPUT:CHAR(*) The buffer to receive the user string. buf_len INPUT:BINARY(4) The size of the buffer. buf_actlen OUTPUT:BINARY(4) The actual length of the user string. If the buf_actlen value is greater than the buf_len value, the data is truncated by the system. errcode I/O:CHAR(*) The structure in which to return error information. Error messages CPF3CF1 E Error code parameter not valid. CPF3C1D E Input variable length in parameter &1 not valid. HTPA001 E Input parameter &1 not valid.
-
Required parameter group grplist INPUT:BINARY(4) The group list handle returned from a call to the QzhbCreateGroupList or QzhbOpenGroupList API. grp INPUT:BINARY(4) The group handle returned from a call to the QzhbGetNextGroup, QzhbFindGroupInList, or QzhbAddGroupToList API. user INPUT:CHAR(*) The user name to be added to the group. user_len INPUT:BINARY(4) The length of the user string. The length must be greater than or equal to 1.
-
4 errcode Threadsafe: Yes I/O Char(*) Use the QzhbRemoveUserFromGroup API to remove a user from an in-memory group. Authorities and locks None. Required parameter group grplist INPUT:BINARY(4) The group list handle returned from a call to the QzhbCreateGroupList or QzhbOpenGroupList API. grp INPUT:BINARY(4) The group handle returned from a call to the QzhbGetNextGroup, QzhbFindGroupInList, or QzhbAddGroupToList API.
-
Chapter 3. Using Net.Data to Write CGI Programs for You This chapter discusses Net.Data for AS/400. Net.Data is an application that runs on a server and allows you to easily create dynamic web documents that are called web macros. Web macros that are created for Net.Data have the simplicity of HTML with the functionality of CGI-BIN applications. Net.Data makes it easy to add live data to static web pages. Live data includes information that is stored in databases, files, applications, and system services.
-
environment to be processed. The language environment processes the information and returns the results to the web macro processor. After all parsing is done and language environment processing is completed, all that remains is pure HTML text. This text can then be interpreted by any browser. The web macro writer has complete control over the level of HTML it uses and what HTML tags are applied. The web macro processor imposes no restrictions.
-
Chapter 4. Using Persistent CGI Programs Overview of Persistent CGI . . Named Activation Groups . Accept-HTSession CGI Header HTTimeout CGI Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 81 81 82 Considerations for using Persistent CGI Programs . . . . . . . . . . . Persistent CGI Program Example . . . . . . . . 82 .
-
/path/cgi-name/handle/rest/of/path Where handle is an exact match of the handle provided in the ″Accept-HTSession″ CGI header for the program cgi-name. Note: The cgi-name that is being resolved is the name as it appears in the URL. It is not necessarily the actual name of the program being started on the system. This is to remain consistent with the name resolution performed by the server.
-
Persistent CGI Program Example The following example shows a counter that is increased each time the Persistent CGI program is called. /***********************************************************************/ / This is a sample Persistent CGI program */ / This program is invoked by a URL */ / http://hostname/cgi-bin/samplePersistent.pgm?bin=1) */ /***********************************************************************/ #include #include #include
-
printf(" Valor count: %i",count); printf("
-
Chapter 5. Enabling your AS/400 to run CGI programs How to enable the server to run CGI programs . Using directives for security and access control . The default fail rule . . . . . . . . . . 85 . 86 . 87 Explicit CGI enablement . . . Server runs only CGI programs. CGI program considerations . . . . . . . . . . . . . . . . . . . 87 . 87 . 87 This chapter discusses the specific steps you need to take to enable your AS/400 for Common Gateway Interface (CGI) programs.
-
a. Add a Pass directive using the WRKHTTPCFG command. Pass /sample /qsys.lib/samplel.lib/samplef.file/samplem.mbr Where samplel is the library, samplef is the file, and samplem is member name in which the AS/400 stores this document. b. Set the source type of samplem member to HTML(CHGPFM). Access to file is *USE for QTMHHTTP or *PUBLIC(GRTOBJAUT). v To store it in the Integrated File System webtest directory: a. Add a Pass directive using the WRKHTTPCFG command. Pass /sample /webtest/sample.
-
v The default fail rule means that only requests that are authorized by the web administrator are honored; other requests will fail.
-
If the CGI program is covered by a protection directive that calls for basic authentication, the user must supply a user ID and password before the CGI program is allowed to run. The other protection subdirectives determine the following: v How the server validates the user ID and password v What security environment the CGI program runs in The subdirectives might tell the browser to treat the user ID as an AS/400 user profile and to validate the password against it.
-
Chapter 6. Sample programs (in Java, C, and RPG) This chapter contains samples of coding in Java, C, and RPG languages. You can locate other programming samples through the following uniform resource locator (URL): http://www.as400.ibm.com/tstudio/index.htm Example of Java language CGI program The samplejava program takes environmental and form variables and displays them back to the browser. import java.io.DataInputStream; import java.util.Hashtable; import java.util.
-
samplejava() { String userMethod; String cl; cl = new String(); // Get the REQUEST_METHOD variable (POST or GET) userMethod = System.getProperty("REQUEST_METHOD"); if (userMethod != null) { if (userMethod.equalsIgnoreCase("POST")) { System.out.println("Server method not supporting"); System.exit(0); } else { // if the method is GET if (userMethod.equalsIgnoreCase("GET")) { // Get the Value of Query String cl = System.getProperty("QUERY_STRING"); } else { errMsg("Invalid REQUEST_METHOD specified"); System.
-
private Hashtable parseArguments (String query_string) { Hashtable cgi_vars = new Hashtable(); // get the first token scan for the '&' char StringTokenizer stringToken = new StringTokenizer(query_string,"&"); while (stringToken.hasMoreTokens()) { index++; // Split the first token into Variable and Value StringTokenizer subToken = new StringTokenizer(stringToken.nextToken(),"="); // Remove the '+' char from the Variable String variable = plussesToSpaces(subToken.
-
private int hexValue(char c) { int rc; switch(c) { case '1': rc = 1; break; case '2': rc = 2; break; case '3': rc = 3; break; case '4': rc = 4; break; case '5': rc = 5; break; case '6': rc = 6; break; case '7': rc = 7; break; case '8': rc = 8; break; case '9': rc = 9; break; case 'a': case 'A': rc = 10; break; case 'b': case 'B': rc = 11; break; case 'c': case 'C': rc = 12; break; case 'd': case 'D': rc = 13; break; case 'e': case 'E': rc = 14; break; case 'f': case 'F': rc = 15; break; default: rc = 0; bre
-
private void errMsg(String message) { System.out.println("Content-type: text/html\n"); System.out.println(""); System.out.println("
"); System.out.println("Error"); System.out.println(""); System.out.println(""); System.out.println("Error
"); System.out.println("
"); System.out.println(""); System.out.println("An internal error occurred."); System.out.println("The specific error message is shown below:"); System.out.
-
Example of C language CGI program To call the SAMPLEC C program, add the following lines to an HTML form:
-
/*
*/ /* . */ /* . */ /* . */ /* Change the form method to "GET" when input data for sample CGI */ /* program comes from the QUERY_STRING environment variable.
-
/* Exit Error: None */ /* */ /**********************************************************************/ void writeData(char* ptrToData, int dataLen) { div_t insertBreak; int i; /*------------------------------------------------------------------*/ /* Write dataLen bytes of data from ptrToData.
-
/* before writing any html text. This indicates the end of the */ /* header and the start of text that is served from the server. */ /* This text is usually html but can be plain/text. */ /* */ /* Input: Data read from standard input or QUERY_STRING that is */ /* entered in an HTML form. */ /* */ /* Output: The data read from standard input is written as is to */ /* standard output. This information would then be served by */ /* the HTTP server.
-
if ( requestMethod ) printf("
REQUEST_METHOD:
%s\n", requestMethod); else printf("Error extracting environment variable REQUEST_METHOD.\n"); /*------------------------------------------------------------------*/ /* html form data can be provided to the CGI program either on */ /* stdin or in environment variable QUERY_STRING. This can be */ /* determined by examining REQUEST_METHOD.
-
/* QUERY_STRING will contain the form data. */ /*--------------------------------------------------------------*/ queryString = getenv("QUERY_STRING"); if ( queryString ) { /*----------------------------------------------------------*/ /* Write the QUERY_STRING data to stdout.
-
**** *** **** This program is a simple RPG program that demonstrates the HTTP *** **** server APIs for reading standard input, reading an environment *** **** variable and writing standard output. This is done using the *** **** IBM AS/400 HTTP Server APIs. *** **** *** **** The HTML at the end of this listing in CTDATA HTML is the text *** **** that is modified by this program, written to standard output and *** **** served to a client.
-
**** client to written to standard output using the QtmhWrStOut API. *** **** The data will be returned as text/html. *** **** *** ************************************************************************** * Variables for the CGI interface API for QtmhRdStIn. DBufIn S 1024a INZ DBufInLn S 9b 0 INZ(1024) DStdInLn S 9b 0 ************************************************************************** * Variables for the CGI interface API for QtmhGetEnv.
-
************************************************************************** * Start of CGI Program execution section... ************************************************************************** * Initialize error code structure for error ids. * This allows for 7 bytes in QUSEI for error message id. C Z-ADD 16 QUSBPRV ************************************************************************** **** Read the Environment variable, REQUEST_METHOD.
-
**** the receive buffer. When this occurs, the **** QtmhGetEnv sets the EnvLen to the actual value **** length without changing the receive buffer. C EnvLen ifgt maxdataln C eval Bufin='Data buffer + C not big enough for + C available input data.' C Z-ADD 80 Result C else C MOVEL EnvRec BufIn C MOVEL EnvLen Result C endif C endif ************************************************************************** **** Read the Environment variable, SERVER_SOFTWARE.
-
C C i ifeq 19 BufOut cat EnvMDResp:0 BufOut * For V4R2, the newline after 254 characters is not needed. C* BufOut cat linefeed:0 BufOut C endif * Add the Environment variable header line for SERVER_SOFTWARE. C i ifeq 20 C BufOut cat html(i):0 BufOut C BufOut cat break:0 BufOut * For V4R2, the newline after 254 characters is not needed. C* BufOut cat linefeed:0 BufOut C endif * Display the Environment variable SERVER_SOFTWARE.
-
C eval alpha1=%subst(c:i:1) C select C when alpha1='-' C eval sign= -1 C when alpha1='.
-
#include #include #include
-
} /* Close config and write contents back out */ QzhbCloseConfig(&cfghdl, &writecfg, NULL); } return 0; Chapter 6.
-
108 Web Programming Guide V4R5
-
Chapter 7. Writing Server API programs Overview of the Server API The Server API allows you to extend the server’s base functions. You can write extensions to do customized processing, such as: v Enhance the basic authentication or replace it with a site-specific process. v Add error handling routines to track problems or alert for serious conditions. v Detect and track information that comes in from the requesting client, such as server referrals and user agent code.
-
v Add Server API directives to your configuration file so that you can associate your program’s application functions with the appropriate step. There is a separate directive for each server request processing step. You must stop and restart the server for the new directives take effect. v Test your program rigorously. Because IBM HTTP Server is a theaded server, you should apply more rigorous testing than you would for a forked server.
-
Service Satisfies the request (such as, send the file or run the CGI) Data Filter Gives write access to the outgoing data stream. Log Allows transaction logging. Error Allows customized responses to error conditions. PostExit Allows cleanup of resources that are allocated for request processing. Server Termination Allows cleanup processing when an orderly shutdown or restart occurs.
-
This function allows user verification of the security tokens. This step is performed based on the authentication scheme. Only HTTP_extract() and HTTPD_set() are valid during this step. Name Translation void HTTPD_LINKAGE NameTrans( unsigned char *handle, long *return_code); This function provides a mechanism for mapping URLs to objects. Only HTTPD_extract() and HTTPD_set() are valid during this step.
-
void HTTPD_LINKAGE write( unsigned char *handle, unsigned char *data, unsigned long *length, long *return_code); This function processes the data and calls the server’s write function with the new or changed data. The application must not attempt to free the buffer passed to it nor expect the server to free the buffer it receives.
-
Value Return code 0 HTTP_NOACTION 100 HTTP_CONTINUE 101 HTTP_SWITCHING_PROTOCOLS 200 HTTP_OK 201 HTTP_CREATED 202 HTTP_ACCEPTED 203 HTTP_NON_AUTHORITATIVE 204 HTTP_NO_CONTENT 205 HTTP_RESET_CONTENT 206 HTTP_PARTIAL_CONTENT 300 HTTP_MULTIPLE_CHOICES 301 HTTP_MOVED_PERMANENTLY 302 HTTP_MOVED_TEMPORARILY 303 HTTP_SEE_OTHER 304 HTTP_NOT_MODIFIED 305 HTTP_USE_PROXY 400 HTTP_BAD_REQUEST 401 HTTP_UNAUTHORIZED 403 HTTP_FORBIDDEN 404 HTTP_NOT_FOUND 405 HTTP_METHOD_NOT_ALLOW
-
that is described in this section. Note that the parameter descriptions use the letter″i″ to indicate input, the letter ″o″ to indicate output, and ″i/o″ to indicate that a parameter is both input and output. Each of these functions returns one of the HTTPD return codes, depending on the success of the request. HTTPD_authenticate() Authenticates a user ID and password. Valid only in PreExit, Authenticate, and Authorization steps.
-
This password is associated with a user that is defined in a validation list (*VLDL) or the password for a user profile on the AS/400 system. IBM HTTP Server for AS/400 does not allow access to the PASSWORD variable if authorization is configured which uses AS/400 user profiles and passwords for authentication. To prevent an application from obtaining an AS/400 user profile password, HTTPD_extract() is sensitive to the type of protect setups that are currently configured.
-
This function is valid in all steps, however not all variables are. The CCSID of the name of the value to set and the buffer which contains the value depends upon the step and the CGI mode. For all steps except Service, these parameters are in the default CCSID of the job. For the Service step, if you are not setting a variable with the ″HTTP″_prefix, then the default CCSID of the job is used. For setting variables prefixed by ″HTTP_″ in the Service step, the CGI output mode determines the CCSID to be used.
-
HTTPD_write() Writes the body of the response. Uses HTTPD_set and HTTPD_extract for headers. Valid in the PreExit, Service, NameTrans, Error, and Data Filter steps. If you do not use HTTPD_set() to set the content type before the first time you call this function, the server assumes you are sending a CGI data stream. You may need to use HTTPD_set() to set the CGI environment variable CONTENT_ENCODING to the appropriate code page for the content of your response before you send the data to the client.
-
The name of the URL for the proxy request and the body of the request are in the default CCSID of the job.
-
10 HTTPD_REQUEST_SERVICED Returned by HTTP_proxy. This return code indicates that the program that called the function completed the response for this request. 11 HTTPD_RESPONSE_ALREADY_COMPLETED The function failed because the response for that request completed processing. Server API configuration directives Each step in the request process has a configuration directive that allows you to indicate which of your application functions you want called and run during that step.
-
Directive Variable Access path Authentication type /QSYS.LIB/MYLIB/MYGWAPI.SRVPGM:function_name NameTrans /URL /QSYS.LIB/MYLIB/MYGWAPI.SRVPGM:function_name IP_address_templete Authorization /URL /QSYS.LIB/MYLIB/MYGWAPI.SRVPGM:function_name ObjectType /URL /QSYS.LIB/MYLIB/MYGWAPI.SRVPGM:function_name Service /URL /QSYS.LIB/MYLIB/MYGWAPI.SRVPGM:function_name* IP_address_template Data Filter /QSYS.LIB/MYLIB/MYGWAPI.SRVPGM:function_name:function_name:function_name Log /URL /QSYS.
-
arbitrary text you want to pass to your application function. Use HTTPD_extract() to extract the text from the INIT_STRING variable. IP_address_template Used only with the Service and NameTrans directives on servers that have more than one IP address. This variable determines if your application function is called only for requests that comes on a specific IP address or on a range of IP addresses. Compatibility with other APIs The Server API is compatible with other APIs, such as CGI.
-
v Write your own separate authorization and authentication application functions. In your configuration file, use both the Authorization and the Authentication directives to specify these functions. Be sure to include HTTPD_authenticate() in your authorization application function. When the Authorization step is run, it performs your authorization application function which, in turn, calls your authentication application function.
-
values you can set or create when processing a client request. For a list of environment variables you can use with Server API, see “Environment variables” on page 13. Server API variables ACCEPT_RANGES Used to accept ranges other than bytes. ALL_VARIABLES All the CGI environment variables. For example: ACCEPT_RANGES ON AUTH_STRING CLIENT_ADDR 9.67.84.3 CLIENT_ADDR IP address for the client. For example: 9.67.193.2 CLIENT_HOST Same as REMOTE_ADDR. CLIENTMETHOD HTTP method that is used in the request.
-
ERROR_INFO Specifies the error code to determine the error page. For example: 401 HTTP_COOKIE Contains the cookie that is sent with this request to communicate state information. For example: CustomerNumber=HJ68944 You can find details about cookies at URL: http://www.netscape.com/newsref/std/cookie_spec.html. HTTP_REASON Sets the reason string in the HTTP response header. HTTP_RESPONCE Sets the response code in the HTTP response header. INIT_STRING The string specified on the ServerInit directive.
-
variable contains the type of data included. You can create your own content type in the server configuration file and map it to a viewer. For example: application/x-www-form-urlencoded PROXY_CONTENT_LENGTH Content-Length header of the proxy request that is made through HTTPD_proxy. When information is sent with the method of POST, this variable contains the number of characters. Servers typically do not send an end-of-file flag when they forward the information by using stdin.
-
SSI_ROOT The path of the topmost file. All include requests must be in this directory or a child of this directory. Example: Note: You can use echo to display a value set by the set or global directives. URI Same as DOCUMENT_URL URL Same as DOCUMENT_URL USERID Same as REMOTE_USER. USERNAME Same as REMOTE_USER. Note: All headers sent by the client (such as Set-Cookie) are prefixed by ″HTTP_″, and their values can be extracted.
-
128 Web Programming Guide V4R5
-
Chapter 8. Writing Java Servlets Servlets are ordinary Java programs that use additional packages (and the associated classes and methods) found in the Java Servlet API. Servlets generate dynamic content for web pages and run on the server. The server can load a servlet automatically when it starts, or when the first client makes a request for the services of the servlet. Once loaded, servlets stay running, waiting for additional client requests.
-
all from a single integrated environment. The VisualAge® for Java servlet builder enables you to visually develop new Java servlets and run-test them automatically in a WebSphere test environment. For more information about Java servlets and the Websphere Application Server, go to URL: http://www.software.ibm.com/webservers/appserv/ .
-
Chapter 9. Using Server-Side Includes This chapter discusses using server-side includes with IBM HTTP Server for AS/400. Server-side includes allow you to insert information into CGI programs and HTML documents that the server sends to the client. This chapter describes the commands that are required to make server-side includes work in your CGI programs and HTML documents.
-
Format for server-side includes The current date, the size of a file, and the last change of a file are examples of the kind of information that can be sent to the client. There are commands that need to be included in the HTML document comments. The commands have the following format: The quotes around value are optional. However, quotes are required for imbedding spaces.
-
timefmt — specify date format: Use this tag to specify the format used when providing dates. Example: Result: ″10/18/95 12:05:33″ Default: ″%a, %d %b-%Y %T %Z″ The following strftime() formats are valid with the timefmt tag: Table 4. Conversion Specifiers Used by strftime() Specifier Meaning %% Replace with % %a Replace with the abbreviated weekday name. %A Replace with the full weekday name.
-
Table 4. Conversion Specifiers Used by strftime() (continued) 134 Specifier Meaning %O[deHlmMSUwWy] If the alternative date and time format is not available, the %E descriptors are mapped to their unextended counterparts. For example, %Od is mapped to %d. %Od Replace with the day of the month, using the alternative numeric symbols. Fill as needed with leading zeros if there is any alternative symbol for zero, otherwise with leading spaces.
-
Note: The operating system configuration determines the full and abbreviated month names and years. Use the echo directive to display the value for specified environment variables using the var tag. If a variable is not found, a (None) is displayed. In addition to the standard Common Gateway Interface (CGI) variables, you can also display the following environment variables: DATE_GMT The current date and time in Greenwich Mean Time. The config timefmt directive defines the formatting of this variable.
-
last-modified replaces the current last modified header value if it is later. You can use the cgi directive to specify the URL of a virtual path to a CGI program. Example 1: Example 2: This example shows the use of variables. You can use the flastmod directive to display the last time and date the document changed. The config timefmt directive defines the formatting of this variable.
-
The following is an example of the HTML coding you need to insert in the child document: Example: Use the include directive to include a document (the text from a document) in the output. You can use the file and virtual tags with the include directive. file - specify file name: Use this tag to specify the name of a file. For the flastmod, fsize, and include directives, the file tag is assumed to be relative to SSI_ROOT if preceded by a ’/’.
-
138 \a Alert (bell) \b Backslash \f Form feed (new page) \n New line \r Carriage return \t Horizontal tab \v Vertical tab \’ Single quote mark \″ Double quote mark \? Question mark \\ Backslash \- Hyphen \.
-
Chapter 10. Troubleshooting your CGI programs You can use the Work with Active Jobs (WRKACT JOB) command to check on the status of server jobs, as follows: WRKACTJOB SBS(QHTTPSVR) JOB(server_instance) When the server is not processing a request, the Work with Active Jobs display might be similar to Figure 1: Work with Active Jobs CPU %: .4 Elapsed time: Type options, press Enter.
-
v No new line character after HTTP response header v No data after HTTP response header. Solution: Write the data to stdout with “Content-type: ” line with two new line characters (“\n”) and the data to be returned to the client. For example: Content-type: text/plain\n \n This data is returned to the client Cause: CGI program caused an exception message that was not handled by the CGI program. Solution: Look at the active server job logs in Figure 1 on page 139.
-
Note: You will probably need additional authority to troubleshoot the CGI program. For example, you will probably need authority to the QTMHHTTP user profile. c. Set breakpoints in the program. d. On the browser, issue a URL that would run the CGI program. The Pass and Exec directives that request the document and run a CGI program must be in WRKHTTPCFG. e. After the system issues an HTTP request on the browser, return to the AS/400 session that ran STRSRVJOB. It should have stopped at a program breakpoint.
-
place they originally appeared. The 0x6B would be converted to 0xF6C2, and the resultant escape sequence would be 0x6CF6C2. For the second approach, leave the data in its EBCDIC form and replace the original escape sequence (three characters) with the single character. In this case, replace 0x6CF2C3 with 0x6B. Note: The CGI program should preserve an escape sequence that represents the character “%”. 3. Call QtmhCvtDB to convert the input stream. Note: 7-bit ASCII CCSID 367 is standard on browsers.
-
The best way to avoid this problem is to use one of the following: 1. Use Exec and Pass directives with mapping: Pass /doc/* qsys.lib/html.lib/* Exec /cgi-bin/* qsys.lib/html.lib/* 2. Put the CGI programs in a separate library: Exec Pass /qsys.lib/htmlcgi.lib/* /qsys.lib/htmldoc.lib/html.file/* Symptom Error 500: Bad script request -- script ’/qsys.lib/qsyscgi.lib/progname.pgm’ not found or not executable Cause: Incorrect match of Exec rule.
-
144 Web Programming Guide V4R5
-
Chapter 11. Notices This information was developed for products and services offered in the U.S.A. IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used.
-
The licensed program described in this information and all licensed material available for it are provided by IBM under terms of the IBM Customer Agreement, IBM International Program License Agreement, or any equivalent agreement between us. COPYRIGHT LICENSE: This information contains sample application programs in source language, which illustrates programming techniques on various operating platforms.
-
Other company, product, and service names may be trademarks or service marks of others. Chapter 11.
-
148 Web Programming Guide V4R5
-
Readers’ Comments — We’d Like to Hear from You AS/400e HTTP Server for AS/400 Web Programming Guide Publication No.
-
GC41-5435-04 ___________________________________________________________________________________________________ Readers’ Comments — We’d Like to Hear from You Cut or Fold Along Line _ _ _ _ _ _ _Fold _ _ _and _ _ _Tape _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Please _ _ _ _ _do _ _not _ _ staple _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Fold _ _ _and _ _ Tape ______ NO POSTAGE NECESSARY IF MAILED IN THE UNITED STATES BUSINESS REPLY MAIL FIRST-CLASS MAIL PERMIT NO.
-
-
Printed in the United States of America on recycled paper containing 10% recovered post-consumer fiber.
-
Spine information: AS/400e Web Programming Guide V4R5