If you use a JSP form that directly manages and accesses request parameters, you should take steps to ensure that no data loss is caused by two or more gears using the same parameter names. The PAF provides the gearEnv.getGear().getId() method that supplies a unique ID that a gear can use as an identifier. These identifiers can be included in well-known request parameters (for example, a hidden form field). Consequently, when the gear checks to see if it should process form input, it can determine whether its unique identifier was included in the request parameters. If it was not included, the gear can ignore the incoming parameter. If it was included, the gear can process the form.

For example, you might include the gear id in a hidden field as follows:

<input type="hidden" name="submit_gear_id"
       value="<%= gearEnv.getGear().getId() %>"/>

Then on the next page you could test to make sure the value of the submit_gear_id gear parameter matches the current gear id before you begin processing the other form parameters, as follows:

String myGearId = env.getGear().getId();
String submittedGearId = request.getParameter("submit_gear_id");
If ((submittedGearId != null) && (submittedGearId.equals(myGearId))) {
...
}

If a gear includes a multipart form (file upload) and other gears need access to the contents of the multipart form, then the gears needing access to the information can be identified by the unique gear identifiers described above. However, in the case of a multipart form, it is preferable to include the gear identification parameter in a query argument so that it can be examined without decoding the multipart form.

 
loading table of contents...