Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

jsp and local interfaces

 
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)?
 
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.
 
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.
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic