Examining form data in an HTTP request

Top  Previous  Next

Form data is information provided by the user through interaction with an element in a HTML form (such as a text input box, button, or check box). The information is transmitted as a series of name and value pairs. XCICS can scan an HTTP request to pick out the form fields, so an application can obtain the data using XCICS commands, without needing to receive and analyze the entire body of the request.

An application can receive the value of a specified form field, or browse through the names and values of all the form fields contained in a request. You can specify code page conversion options if you need to convert the data into a different code page for use by your application.

The Web client sends form data in a query string when the GET method is used, and in the message body when the POST method is used. XCICS can
extract the data from either of these locations, so you do not need to specify which method was used. As an alternative, if the form data is sent in the query string, you can retrieve the entire query string using the WEB EXTRACT command. "Examining the request line for an HTTP request" tells you how to do that.

XCICS only reads form data when XCICS is the HTTP server. The facility is not available when XCICS is an HTTP client.

To obtain the value of a particular field of an HTML form, use the WEB READ FORMFIELD command. Your application program can provide a buffer which will receive the value, or alternatively, you can provide a pointer which XCICS sets to the address of the value. XCICS returns a NOTFND condition if the form data does not contain a field with the specified name. The form data is unescaped by XCICS before it is returned, with the %xx sequences converted back to the original characters.
To browse all the fields in the form data:
1.Use the WEB STARTBROWSE FORMFIELD command to begin browsing the fields.
2.Use the WEB READNEXT FORMFIELD command to retrieve the name and value of each field in turn. Your application program needs to provide two buffers: one receives the name of the field, and one receives its contents. XCICS returns an ENDFILE condition when all fields have been read.
3.Use the WEB ENDBROWSE FORMFIELD command to end the browse when your program has retrieved all the fields of interest.