Dynamo’s DSP tag libraries include several tags that you can use to demarcate transactions in JavaServer Pages:

See the ATG Page Developer’s Guide for more information about these tags.

Transaction Servlet Bean

In addition to the transaction handling tags in the DSP tag libraries, Dynamo has a servlet bean class, atg.dtm.TransactionDroplet, for demarcating transactions, and includes a Nucleus component of this class at /atg/dynamo/transaction/droplet/Transaction. For example:

<dsp:droplet name="/atg/dynamo/transaction/droplet/Transaction">
  <dsp:param name="transAttribute" value="requiresNew"/>
  <dsp:oparam name="output">

  ... portion of page executed in demarcated area ...


In this particular example, the demarcated portion of the page executes in its own separate transaction, as specified by the requiresNew directive. The valid values for the transAttribute input parameter are required, requiresNew, supports, notSupported, mandatory, and never.

Ending Transactions Early

The transaction demarcation mechanisms, such as the Transaction servlet bean, take care of both creating and ending transactions. The application itself does not need to commit or rollback the transaction.

Sometimes, however, you might want to force the transaction to complete. This is usually done if the application needs to determine the outcome of the transaction before reaching the end of the demarcated area. For example, an entire page might be demarcated in a single transaction, meaning that the transaction ends after the page has been served to the user. This is a problem if the user needs to know that there was a problem ending the transaction, because by the time the transaction fails, it is too late to tell the user.

The solution is for the application to end the transaction before the end of the demarcated area. Dynamo has a servlet bean class, atg.dtm.EndTransactionDroplet, for ending transactions, and includes a Nucleus component of this class at /atg/dynamo/transaction/droplet/EndTransaction. For example:

<dsp:droplet name="/atg/dynamo/transaction/droplet/EndTransaction">
  <dsp:param name="op" value="commit"/>
  <dsp:oparam name="successOutput">
    The transaction ended successfully!
  <dsp:oparam name="errorOutput">
    The transaction failed with reason:
    <dsp:valueof param="errorMessage"/>

This causes the transaction to commit or rollback (according to the op parameter), and displays one of the two open parameters, depending on the outcome. The remainder of the page executes without any transaction context, so the page must not attempt to access any resources after ending the transaction (unless it demarcates that resource use with a new transaction demarcation).

For more information about including servlet beans and other Nucleus components in pages, and for more information about the Transaction and EndTransaction servlet beans, see the ATG Page Developer’s Guide.

loading table of contents...