314 IBM Workplace Forms: Guide to Building and Integrating a Sample Workplace Forms Application
ProcessXFDL servlet receiving incoming XFDL documents
Building the servlet can be done using eclipse, RAD6, or any other Java development
environment. The servlet is contained in a single Java file. There is some basic information
needed to configure the servlet. This can be done in the servlet.properties file, or it can be
read from the incoming XFDL document or from any other datasource). What portion of
information comes from what data source will depend on the environment and design guides
in place. In this redpaper we will read all information from servlet.properties file.
The servlet should process the following tasks:
Read setup information (init method). Since our setup information is static (stored in the
servlet.properties file), we can read it in the init method.
– Identify the database and form and field name to store the request document.
– Connect to the database (username/password).
– Detect the data instance ID to extract from the incoming XFDL form.
Receive incoming POST messages (this will be done in the doPost method):
– Extract the Success URL from the incoming message (URL parameter).
– Read the incoming XFDL form.
– Extract the assigned data instance from the XFDL file using the Forms API.
– Read the custom ID from XFDL using the Forms API. This will be the key to search for
a related request document in the target database.
– Prepare the XML stream for the DXLImporter for document creation/update with the
extracted data instance.
– Run the DXLImporter to create/update the request document.
– Store the received XFDL file to the just-created/updated request document as an
attachment.
– Submit the Success URL to the browser.
Receive GET messages (for debug purposes only). The doGet method will submit the
settings read from the servlet.properties file rendered in an HTML page.
The full servlet code is given in Example 9-16. For details, see the in-line comments.
Example 9-16 Listing of full servlet code
/**
* @version 1.0
* @author Cees Vandewoude, Andreas Richter
* @comment Improved simple servlet version for IBM Workplace Forms Integeration
* Redpaper
*/
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import lotus.domino.*;
import java.util.Vector;
Note: The servlet.properties file can store multiple virtual addresses for the same servlet
and assume, for each virtual address, different parameters. This makes it possible to use
one generic servlet processing different XFDL forms.