• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accesing java beans vs ejb's from jsp  RSS feed

 
Chiran Mathur
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell the difference between accesing java beans vs accesing enterprise java beans from jsp's. Conceptually what is the difference and how does one do it...
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well,
i've never done EJB but i know little about it. it would not be a difference due to they are JavaBeans and EJBs, but the difference would be there due the reason that they both are DIFFERENT technology.
with EJB u deal with remote objects hence u end up using JNDI for bean lookup. once u get the ref to remote bean its all same...
with JavaBeans its as simple as using any other Java object. u instantiate it and that it.
using EJB ur JSP page can use any Bean Object available within the n/w using naming resolution but with simple Beans u can access only beans on ur server.
again, u might be using EJBs from ur local Beans which is perfectly possible.
i don find any meaning in comparing the access methods u r talking about...
experts???
regards
maulin.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a regular JavaBean, you can just use the "jsp:useBean" and Bob's your uncle. There's no such easy way in with EJB's - you have to do a JNDI lookup to find the bean's Home interface, then create or find using one of the home methods.
So why go to all that much trouble? Because EJBs have some useful attributes:
1. They have built-in transaction controls
2. You can use an abstract persistency mechanism instead of coding the DBMS details in application code
3. Most EJB containers provide a cache mechanism for better performance of frequently-referenced items.
4. You can provide services to multiple client machines.
5. Some EJB systems also allow clustering support, so that EJB services can be distributed for better workload balancing and failover support.
It's not uncommmon for a JavaBean to be a used as a proxy for an EJB. That way the JSP conveniences for JavaBeans can be used, and the JNDI/home ugliness is safely tucked out of sight inside the proxy JavaBean.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!