• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I'm Confused...

 
Jon Bryant
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Peter Rooke
Ranch Hand
Posts: 847
1
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jon Bryant
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jon Bryant
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Cool. That answers it. Thanks!
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're very welcome Jon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic