• 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

JBoss, EJB and JSP

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Gurus,
Can someone tell me how to call EJB from jsp page in JBoss... i have tried using the same context.lookup technique but it didnt work.
Is there any other way of calling ejb components from JSP in JBoss, like in weblogic we can make tag library and can then deploy the war file.
Thanks in advance
Regards,
Harjinder
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to consider using a proxy object behind the JSP. Reference this object using the <jsp:useBean ..> tag and in the constructor of this object lookup the SessionBean.
Use this proxy object to delegate the requests from the JSP to the SessionBean behind it.
Have fun,
Mat.
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the standard method of looking up EJBs does work from JSP pages - you just have to make sure that you import all the right classes.
As Mat says, you can use a proxy object, while another alternative is to use a custom tag to wrap up the JNDI lookup for you. Take a look at Chapter 8 : Tag Patterns (from Professional JSP Tag Libraries) for an example of how to achieve this.
These are all great ways to access EJBs from a JSP page, but are really suited to smaller applications because from an architectural perspective, accessing enterprise resources from JSP pages (the view components) tends to go against some of the best practices such as MVC, also known as the web application model 2 architecture, particularly for larger applications. In model 2, the view components are just that - responsible for presenting information held in the model.
Take a look at Chapter 12 : Designing Web Applications and Servlet Patterns (from Professional Java Servlets 2.3) for more information on the model 2 architecture.
Hope that's useful...
Simon
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi;
Well it is a good practice to look up ejbobject via custom tag.
But if there is an href or submit button in your jsp page use mvc and in command class use ejbCommand pattern and in that serializable class of ejbCommand paterrn by using ejbhome factory pattern call ejb object.
Jawwwd Ahmed
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jawwad ahmed:
Hi;
Well it is a good practice to look up ejbobject via custom tag.


Well, certainly better than all that nasty Java code embedded in the JSP.
 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gurus,
Thanks for the quick response.well actually i have just started EJB and i have done it using weblogic server where u can acces EJB from JSP using tag lib. but now i wanna do the same thing in JBoss, and i dont know how to make that proxy object and jndi look up.can u paste a sample code here as that will be easy for understanding.
Thanks in advance
Regards,
Harry
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well u can download free pdf and examples from sourceforge.net also documentation of 2.4 available on jboss.org/onlinemanual search from google.Frm that at least u can getstart.
Thanks
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic