The dsp:beginTransaction tag initiates a transaction and tracks whether the transaction is created successfully. Initiation failures are captured by the tag as a Throwable exception object. This tag creates an EL variable that enables later tags to reference the transaction access its 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 object identified 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 start transaction operation. A call to isSuccess returns true.
exception
The exception property identifies the Throwable exception object produced when a transaction does not start properly. A call to getException returns the exception object.
Example
<dsp:beginTransaction var="beginXA"/>
<c:choose>
<c:when test="${beginXA.success}">
The transaction was started successfully<br/>
</c:when>
<c:otherwise>
Transaction failed due to this exception:
<c:out value="${beginXA.exception}"/>
</c:otherwise>
</c:choose>
In this example, the tag causes a transaction to begin. If the call is successful, the user sees the message The transaction was started successfully. If the call fails, the user sees the message Transaction failed due to this exception and the exception is displayed.

