Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access EJB in JSP???  RSS feed

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to JSP & EJB. I ve cmp2.0 EJB already deployed on the other Server (JBOSS 4.0). Now i want to access these beans from the other machine (diferent container) . How to access it??? I think if the JSP & Beans are in same container then we can access it using --
<jsp:useBean id="myBean" scope="page" class="myPackage.MyBean" />

Now in above code where is the code for lookup JNDI name for bean??? like intialising context & looking up for JNDI name of bean.

Please help me.

Thanx.

Prash
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The useBean feature doesn't work for EJBs. It is meant for beans under the control of the servlet container, which isn't the case for EJBs. You will have to use JNDI. It would be a better design to leave this out of the JSP page, and handle it in a separate business object, which is accessed either through a servlet, or a bean accessed via useBean.
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanx fo ryour instant reply.
But one question is still in mind. I am using JBOSS4.0. As u told I should use seperate business object which is under control of servlet container. So in order to acces the EJB through this business object which files of the EJB are necessary to include in the web project. Is the home interfece file & remote interface file alone are sufficient to include in web project??
And also in the "jsp:usebean" tag we are specifying property attribute. It means we have to write again getters & setters in this business object class controlled under servlet container which will represent propety attributes. Is it the right method (standard) for web application???
Please help me.
Thanx in advance.

Prash
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!