Initiating A Transaction From A Servlet - Red Hat APPLICATION SERVER - JONAS Tutorial

Jonas
Hide thumbs Also See for APPLICATION SERVER - JONAS:
Table of Contents

Advertisement

Chapter 8. Accessing Beans From a Servlet

8.3. Initiating a Transaction From a Servlet

It is better to initiate the transactions from the beans, however in some cases you want the transaction
to be initiated from the servlet. In this case, proceed as follows:
...
try
{
Context initialContext = new InitialContext();
UserTransaction utx = (javax.transaction.UserTransaction)
initialContext.lookup("java:comp/UserTransaction");
utx.begin();
... do some interesting work here ...
if (success)
utx.commit();
else
utx.rollback();
}
catch (Exception ignore)
{
return ;
}
...
37

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the APPLICATION SERVER - JONAS and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Application server

Table of Contents