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
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.
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 JavaServlets 2.3) for more information on the model 2 architecture. Hope that's useful... Simon
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
sharp shooter, and author
Joined: May 10, 2000
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.
Joined: May 02, 2001
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
Joined: Dec 01, 2001
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