aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes I'm Confused... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "I Watch "I New topic
Author

I'm Confused...

Jon Bryant
Greenhorn

Joined: Mar 23, 2005
Posts: 3
Ok. So I have this database and a nifty Entity bean to talk to it. I also have this super-cool JSP that I want to use to display the database information (via the EJB). But, how do I get the two to talk to each other?

I've read (most of) the HF EJB and Servlets & JSP books, but I'm looking for the way to put the two together. They don't seem to cover that...

Thanks!


The three principal virtues of a programmer are Laziness, Impatience, and Hubris. -- Perl man page
Peter Rooke
Ranch Hand

Joined: Oct 21, 2004
Posts: 804

Core J2EE Patterns - Business Delegate.
Core J2EE Patterns - Session Facade

Of course you could just use the local ejb [stub] interfaces directy within your web application, if they are in the same container.

PS - "I'm Confused...", EJB's are like that
[ March 23, 2005: Message edited by: Peter Rooke ]

Regards Pete
Jon Bryant
Greenhorn

Joined: Mar 23, 2005
Posts: 3
Thanks for the links: they were helpful, but that wasn't really what I was asking. I guess I should be more specific.

Do I have to put a scriptlet into my JSP to do an EJB lookup to use the Entity Bean or is there a way to put it in the DD as a parameter so I just have access to it as a variable (just like "session" or "page")? In the HF books, they say you can declare this in the DD and how to, but it doesn't show me how this works in the JSP. Or, if it does (somewhere else in the book), I'm not making the connection...
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Jon,

I suppose they will explain you how to declare ejb references in the deployment descriptors. They might also explain you how to build a bean class that does the lookup and use jsp:useBean tag within the jsp in order to call the bean and does the actual lookup. Another common technique is to use an MVC controller like struts, lookup the bean inside an action class and add the home interface as an attribute to the HttpRequest object. Latter on you can use the same jsp:useBean for getting the reference to the bean�s home interface. Bottom line is that there are several techniques for making jsp looking like they use ejb like build-in objects, but this is actually not quite true. Somewhere, somehow within your application you must write a piece of code that dos the actual lookup.
Regards.


I think, therefore I exist -- Rene Descartes
Jon Bryant
Greenhorn

Joined: Mar 23, 2005
Posts: 3
Ok. Cool. That answers it. Thanks!
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
You're very welcome Jon
 
 
subject: I'm Confused...