1.8. Element `post`
Prev | 1. Reference | Next

### 1.8. Element `post`

    <post
      url = anyURI
      valueCharset = Any encoding supported by Java : ISO-8859-1
      readResponse = boolean : false
    >
      Content: [ field ]+
    </post>

    <field
      name = Form field name (US-ASCII only)
    >
      Content: value | file
    </field>

    <value>
      Content: xs:string
    </value>

    <file
      name = Path
      contentType = Content type
    />

Emulates an HTML form possibly containing `input type="file"` elements. The `post` element posts the content of the emulated form to the CGI or Servlet specified by attribute `url`, using the `multipart/form-data` method.

An emulated form field has a name specified by required attribute `name`. There are two type of fields:

value

  Emulates `input type="text"` or `input type="hidden"` elements found in an HTML form. The content of this element, a possibly empty string, specifies the value of the field.

  Attribute `valueCharset` of the `post` element specifies the charset used for all `value` fields. By default, this charset is `ISO-8859-1`.

file

  Emulates `input type="`f`ile"` elements found in an HTML form. The `name` attribute of this element specifies the filename of the file to be uploaded.

  Unless specified, the content type of the file is guessed using the extension of the filename. If the filename ends with:

  .zip

    the content type is supposed to be `application/zip`;

  .jar

    the content type is supposed to be `application/x-java-archive`;

  .xml

    the content type is supposed to be `text/xml`.

  Otherwise, the content type is supposed to be `application/octet-stream`.

If attribute `readResponse` is specified with value `true`, this element returns the response of the server. Otherwise, this element returns no result at all.

Moreover, for this element to return a result, the server must respond to the post request with a success code different from "`No Content`" (204) and must send "`text/*`" data (e.g. "`text/plain`", "`text/html`", etc). If the content type of the sent data has no charset, the data is read as a string using charset "`ISO-8859-1`".

Examples:

    <post url="http://localhost:8080/measure/archive">
      <field name="op">
        <value>add</value>
      </field>
      <field name="user">
        <value>%U</value>
      </field>
      <field name="data">
        <file name="/tmp/1052_3_CO_3.1R" />
      </field>
    </post>

    <post url="http://localhost:8080/measure/archive"
          valueCharset="US-ASCII" readResponse="true">
      <field name="op">
        <value>add</value>
      </field>
      <field name="user">
        <value>%U</value>
      </field>
      <field name="interactive">
        <value>false</value>
      </field>
      <field name="data">
        <file name="1052_3_CO_3.1R"
              contentType="text/xml; charset=ISO-8859-1" />
      </field>
    </post>

Unless used in XMLmind XML Editor Professional Edition, this element will cause its parent process command to be disabled.

Prev | Up | Next
1.7. Element `upload` | Home | 1.9. Element `print`