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...
The three principal virtues of a programmer are Laziness, Impatience, and Hubris. -- Perl man page
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 ]
Joined: Mar 23, 2005
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...
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.