• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB and JSP

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I call ejb from a jsp. I hane a package ProjectHome with two entity classes, project1.java and Project2.java. I also have an ejb ProjectEJB.java. I want to call this page from a jsp page. Any example you have will be fine. I will just modify it
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic