Can my JSP pages be "transctive" and initiate a transaction or is this possible only with EJBs?

Bozidar Dangubic

A Jsp compiles into a servlet. According to the specification, a servlet can start and commit/rollback its own transactions. So, you can obtain a user transaction from JNDI via java:comp/env/UserTransaction from within your scriptlet code and fire away!

Content ic = new InitialContext();
UserTransaction ut = (UserTransaction) ic.lookup("java.comp/UserTransaction");
try {
   //transactional stuff
} catch (Exception e) {
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact