• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp and local interfaces

 
Sany Bel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we lookup a entity beans local interface through action classes (Struts)?
 
Victor Larr
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In WebSphere you can even access local ejb directly in jsp page
 
Sany Bel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you do the jndi lookup? Can you give an example.
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Victor Larr
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic