invoke a ejb (ejb include jta operate) in span jsp file ,can running sucessful????
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, April 21, 2004 07:32 PM

i use the tomcat server and a ejb server envirmoment. some logic code is like these: //ship is a ejb //in ship object will start the transaction in ejb server. class ship { UserTransaction ut=null; public void begin() { ut=new UserTransaction ut.begin(); } public void add(String nn) throws Exception { invoke some ejb save some data into database } public void commit() { ut.commit(); } public void rollback() { ut.rollback(); } } and this ejb will be save into http session and invoke in tomcat servel jsp file. a complete operate    More>>
			i use the tomcat server and a ejb server envirmoment.
			
some logic code is like these:
//ship is a ejb
//in ship object will start the transaction in ejb server.
class ship
{
UserTransaction ut=null;
public void begin()
{
ut=new UserTransaction
ut.begin();
}

public void add(String nn) throws Exception
{
invoke some ejb
save some data into database
}
public void commit()
{
ut.commit();
}
public void rollback()
{
ut.rollback();
}
}


and this ejb will be save into http session and invoke in tomcat servel jsp file.


a complete operate like these
step
1 )file1.jsp
create the ship ejb object
invoke the ship ejb begin method.
2 )file2.jsp
get the object from httpsession ,
invoke the ejb add method to save information,
product data ...
3)file3.jsp
get the object from httpsession
invoke the rollback method from ejb object or do the
commit method .

eg) state of this span jsp file runnning when multi-user execute it.
i) state (one user)


browser tomcat server
client 1 ----request file1.jsp ---- link to thread 1
client 1 ----request file2.jsp -----link to thread 1
client 1 ----request file3.jsp -----link to thread 1

if like that ,that program can runnning sucessfull.
and in this span jsp file ,i have use the out.println(Thread.currentThread.getName());
so i can confirm that servel request is in same thread1.
if like this state ,jta will not be error.because all is running in same thread.

II )state (multi-user)
browser tomcat give a thread to process
the client request
client1 --------request file1.jsp------- Thread1
client2 --------request file 1.jsp------- Thread2
client1 ---------request file2.jsp-------Thread3
client2----------request file2.jsp ----- thread2
client2----------request file3.jsp -------Thread2

like the client2 state jta will not get any error and can execute sucessful.
if the state like the client1 ,how the jta solve this problem??
thanks you very much.

file1.jsp ,file2.jsp and file3.jsp all there file is use to operate a ejb object ,but that ejb object include the JTA ,and invoke other entity bean.


my problem is ,who can explain how the JTA solve this problem and execute it like that state.
   <<Less
About | Sitemap | Contact