wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes jsp and local interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "jsp and local interfaces" Watch "jsp and local interfaces" New topic
Author

jsp and local interfaces

Sany Bel
Ranch Hand

Joined: Mar 12, 2004
Posts: 51
Can we lookup a entity beans local interface through action classes (Struts)?


--------------<br />Sany Bel<br />SCJP 1.4, SCBCD
Victor Larr
Greenhorn

Joined: Mar 29, 2004
Posts: 16
In WebSphere you can even access local ejb directly in jsp page
Sany Bel
Ranch Hand

Joined: Mar 12, 2004
Posts: 51
How do you do the jndi lookup? Can you give an example.
Santosh Ramachandrula
Ranch Hand

Joined: Apr 04, 2004
Posts: 252
Hello Victor Larr,
In WebSphere you can even access local ejb directly in jsp page
1. Does the above behaviour happen only if the web application and enterprise bean are in the same JVM?
2. Is the above behaviour true if the web application and enterprise bean are in different JVM's (I think the above behaviour will not be exhibited in case number 2, if it does then I don't understand EJB's )?

Sany Bel -->

Can we lookup a entity beans local interface through action classes (Struts)?

I think you can if struts application and enterprise bean are in same JVM otherwise not.
Thanks,
Santosh


Thanks,
Santosh
Victor Larr
Greenhorn

Joined: Mar 29, 2004
Posts: 16
Yes you can access local EJB only if web container and ejb container runs inside the same JVM. For ejb lookup you put the same code in jsp as in a regular java class.
<%
Context context = new InitialContext();
MyEJBHome home = (MyEJBHome)context.lookup("myEJB");
MyEJB ejb = home.create();
%>
It is good for testing. But in a real development this code should be moved to a helper class.
 
 
subject: jsp and local interfaces
 
Similar Threads
Are variables defined inside a constructor instance or local?
String operation
Did implicit objects are instance variables or local variables in _jspService
Resource Local Transactions
object/collection modification