i think is better to see the source code.
file:1.jsp
InitialContext ic = new InitialContext();
Object obj = initialcontext.lookup("ejb/ShoppingCart");
ShoppingCartHome sch = (ShoppingCartHome)
PortableRemoteObject.narrow(obj, abayi.ShoppingCartHome.class);
ShoppingCart sc=sch.create();
/**
*sc.begin() this method is include the jta "UserTransaction
*Object in internal" and this begin method will invoke the
*UserTransaction.begin this method
**/
sc.begin();
session.setAttribute("sc",sc);
response.sendRedirect("2.jsp");
file:2.jsp
ShoppingCart sc=(ShoppingCart)session.getAttribute("sc");
String data=request.getParameter("item");
if(data!=null)
sc.add(data);
%>
<form action=2.jsp>
<input type=text name=item>
<input type=submit>
</form>
<form action=3.jsp>
<input type=submit name="COMMAND" value="COMMIT">
</form>
<form action=3.jsp>
<input type=submit name="COMMAND" value="CANCEL">
</form>
<%
file:3.jsp
<%
ShoppingCart sc=(ShoppingCart)session.getAttribute("sc");
if(request.getParameter("COMMAND").equals("COMMIT"))
{
/**
*this commit method is include the jta commit method.
*
**/
sc.commit();
}
else
{
//this method is invoke the jta rollback method.
sc.rollback();
}
response.sendRedirect("index.html");
%>
==========================================================
my problem is will this code will get error .