<dsp:beginTransaction var-spec>
   ...
</dsp:beginTransaction>

Attributes

var-spec

An EL variable or scripting variable that is defined with one of these attributes:

Attribute

Description

var

Names an EL variable. When you use var, you can set its scope attribute to page, request, session, or application. The default scope is page. For more information, see EL Variable Scopes.

id

Names a scripting variable that scriptlets and expressions can access at runtime.

The variable has one of the following properties:

See Usage Notes for more information on these status codes.

Usage Notes

dsp:transactionStatus retrieves the status of the active transaction and saves that status the specified variable’s statusString property. Other tags can query the variable for transaction status information. If the tag is unable to access status information, the success property is set to false and the exception property holds a Throwable exception.

The variable can be tested for one of the following Boolean properties:

active

Indicates whether the transaction is in its early stages of operation and has not received any instructions about how to end.

committed

Indicates whether tasks associated with the transaction executed, any changes made to a database(s) as a result were saved, and the transaction ended.

committing

Indicates whether tasks associated with the database are in the process of committing. It is most likely that the transaction involves multiple databases, of which some have committed data and others do not.

markedRollback

Indicates whether the transaction has been instructed that, when it is prompted to end, it must revert the database(s) to its pre-transaction state (rollback).

noTransaction

Indicates whether any transaction is associated with current request thread.

prepared

Indicates whether each database involved in the transaction has verified that it can commit the transaction without any errors.

preparing

Indicates whether each database involved in the transaction is investigating whether it can commit the tasks associated with the transaction.

rolledback

Indicates whether the tasks associated with the transaction did not complete and so no changes were made by the transaction. The transaction ended.

rollingback

Indicates whether that the transaction is in the process of undoing any tasks that it performed, so no changes are saved.

unknown

Indicates whether the transaction manager can recognize the status of any other status properties.

Example

<dsp:transactionStatus var="statusXA"/>
  <c:choose>
    <c:when test="${statusXA.committed}">
      Congratulations! You will graduate this June!
    </c:when>

    <c:when test="${statusXA.rolledBack}">
      You will not graduate this year. Be sure to enroll in classes for
      next semester.
    </c:when>

    <c:otherwise>
      It takes 10 days to gather your records and process them. Check
      again in a few days.
    </c:otherwise>
  </c:choose>

In this example, the status of the transaction determines the message a user sees. The transaction status is set in the EL variable statusXA that is defined by dsp:transactionStatus. When the status is rolledback users see one message, when it is committed they see another. All other transaction statuses provide the same in process notification to their recipients.


Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices