• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

why JSP and servlet has to work differently for EJB Lookup?

 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
From servlet if I want to access an EJB, I would configure ejb-ref tag in the web.xml and then use java:comp/env/ejb thing to lookup home interface of an EJB BUT with JSPs I don't think I can do it. I have to use INITIAL_CONTEXT_FACTORY and PROVIDER_URL and then I can get Remote interface access of any EJB in my JSP, right?
Why such a difference in access of an EJB if JSPs "are supposed to servlets ultimately"?
Or I am missing anything. Are there any app server vendor specific methods to use EJBs via java:comp/env/ejb from JSPs??
Regards
Maulin
 
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSPs are supposed to be views, not controllers. No?
I thought EJB 2.0+ recommended taking the factory and the URL out of the initial context fetching operation. It makes your code more container dependent. Websphere 5+ recommends just

Except when one is clustering.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maulin Vasavada:
Hi all,
From servlet if I want to access an EJB, I would configure ejb-ref tag in the web.xml and then use java:comp/env/ejb thing to lookup home interface of an EJB BUT with JSPs I don't think I can do it. I have to use INITIAL_CONTEXT_FACTORY and PROVIDER_URL and then I can get Remote interface access of any EJB in my JSP, right?
Why such a difference in access of an EJB if JSPs "are supposed to servlets ultimately"?
Or I am missing anything. Are there any app server vendor specific methods to use EJBs via java:comp/env/ejb from JSPs??
Regards
Maulin


You're missing something. EJB references declared in the web.xml should be accessible within JSP's as well as servlets so long as they are contained within the same web application.
Kyle
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup Kyle
I was missing that. I realized when I wrote JSP It works same way in servlets/jsp both...
Regards
Maulin
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic