File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Transactions in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Transactions in Servlet" Watch "Transactions in Servlet" New topic

Transactions in Servlet

Ashish Pagare
Ranch Hand

Joined: Oct 14, 2003
Posts: 101
I have a basic question about how to achieve transaction capability in a servlet. How do u achieve the rollback capabilites if a database save fails?
I hope some one will shed some light.
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
you would do it the same way as you would in any java program, so this would be better posted in one of the database forums. personally i dunno

Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Ashish Pagare
Ranch Hand

Joined: Oct 14, 2003
Posts: 101
Thanks for replying Tim.
I understand that I can do the manual commit and rollback based on scenario. I am interested in knowing what is the approach taken to build jsp/servlet based projects. Like app servers provide transaction capabilites for EJB do we have anything for servlet.
Second thing which I have is how to simulate 2 phase commit in jsp/servlet.
I mainly work in middleware applications so not much acquainted with how to achieve the same in front end tier.
May be some other front end genius will help me here.
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
It is possible to start and commit a JTA transaction in many servlet containers, thus allowing for 2-PC. However, not all servlet containers provide JTA support, although the two leaders (WebSphere and WebLogic) do.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Don't get me started about those stupid light bulbs.
subject: Transactions in Servlet
It's not a secret anymore!