This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes BEA/Weblogic and the fly likes EJB and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "EJB and JSP" Watch "EJB and JSP" New topic


Nolundi Irene Tiya

Joined: Apr 07, 2004
Posts: 1
How do I call ejb from a jsp. I hane a package ProjectHome with two entity classes, and I also have an ejb I want to call this page from a jsp page. Any example you have will be fine. I will just modify it
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
EJBs are used from JSPs the same way they are used anywhere else. The process is pretty simple:
  • Get an InitialContext.
  • Lookup the EJBHome.
  • Use the EJBHome to create, find, or remove EJB instances.

  • A quick example looks like:

    The above example assumes that the client also resides within the same Container and that the EJB is a local Stateless Session Bean.
    Now, you could drop this code directly into your JSP but that would be poor design. Remember, we would like to keep as much code out of the JSP as possible. In this case it would be more desirable to create a Business Delegate to call from the JSP and possibly even a custom tag.
    I agree. Here's the link:
    subject: EJB and JSP
    It's not a secret anymore!