The dsp:commitTransaction tag completes the current transaction and, in so doing, causes all tasks encapsulated by the transaction to execute immediately. This tag tracks whether the transaction has completed successfully, and when not, saves a Throwable exception object.
This tag creates an EL variable that represents the transaction object, which later tags can reference and use to access the object’s success and exception properties.
Attributes
TagVariable:varorid(Required)
You must define an EL variable or scripting variable:
Attribute | Description |
|---|---|
| Names an EL variable. When you use |
| Names a scripting variable, which scriptlets and expressions can access at runtime. |
VariableScope:scope
The scope attribute determines where the EL variable named by the var attribute is stored and what resources can access it. Options include: page, request, session, or application. Omitting this attribute causes the default, page, to be used.
Properties
success
The success property specifies the status of the transaction’s completion. A call to isSuccess returns true.
exception
The exception property identifies the Throwable exception object produced when the tasks associated with a transaction are not executed. A call to getException returns the exception object.
Example
<dsp:commitTransaction var="CommitXA"/>
<c:choose>
<c:when test="${CommitXA.success}">
The transaction was committed successfully!<br/>
</c:when>
<c:otherwise>
You have failed! Here's the exception:
<c:out value="${CommitXA.exception}"/>
</c:otherwise>
</c:choose>
In this example, the tag causes a transaction to be committed. If the transaction is successfully committed, the message Congratulations! The transaction was committed successfully. is displayed. If the transaction fails to commit, the user sees the message The transaction was not committed because of this exception, followed by the exception.

