3.3.3 Adding Parameters to the Dataset

You may wish to add extra data to the parameter set before calling the Tuxedo service. For example, you may need to add a parameter representing the date and time of the request. You would not expect to receive this parameter from the FORM data in the HttpServletRequest. Instead, add it in the servlet, then submit the augmented data set to the Tuxedo service. The following example illustrates this procedure:

// Create a new dataset
ServletDataSet dataset = new ServletDataSet();
// Import the HttpServletRequest into the dataset.
dataset.importRequest(request);
// Insert an extra parameter into the dataset.
dataset.setValue("REQUEST_TIME", (new Date()).toString());
// Send the dataset to the named service.
ssPool.call("service_name", dataset, null);

This code example demonstrates the manual conversion of the HttpServletRequest object into a ServletDataSet object. In this new format you can add extra parameters using the setValue() method. The new value is associated with a key, represented by a string. Next, the call() method that is inherited from the SessionPool is invoked. This method accepts the ServletDataSet class, but requires an extra argument for use with transactions. Supply null for this last parameter, indicating that you are not using a transaction to group multiple session calls. See “Using a Transaction” for more details.