• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing EJBs from JSP  RSS feed

 
Herbert Maosa
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering how I can access an EJB from a jsp page. I have an EJB (Entity) that I can execute from an application client. I want to create a web client for it, in the form of JSP.But I am wondering what I should do to execute the EJB in the jsp page.
Herbert.
 
Anand Srinivas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Herbert,
One way of doing this is to have a servlet in between to execute the EJB and transfer the results to the JSP. The servlet will be invoked by the JSP and the servlet shall contain the necessary coding for invoking the EJB and the result can be displayed with JSP again.
Regards,
Anand Srinivas
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, it is a REALLY BAD idea to directly access an Entity bean from any kind of client -- Java Application, Servlet, or JSP. You need to wrap your Entity EJB access in a Session Facade.
See this article. Not only do the arguments there apply, but also, each access to an Entity bean (every getter) that is not wrapped in a client transaction (which is also a bad idea) is a new transaction, which results in at least one SQL call....
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!