aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Accessing an EJB into a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accessing an EJB into a JSP" Watch "Accessing an EJB into a JSP" New topic
Author

Accessing an EJB into a JSP

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I deployed an EJB in WebLogic5.1 and Configured the property file of the weblogic to support JSP and I created a JSP file and plased it in the dir c:\weblogic\myserver\public_html. then I can access it from the localhost:7001\myjsp.jsp. But if i want use that EJB in a JSP, I want Help where to place the Bean class (i am asking the compleate path)and where will it needs to put the jar file and also what will be the package i need to plase in the JSP file. Can any one help me (if possable with a sample code) Thanks in advance.
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
I am moving this post to J2EE and EJB forum.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Yugandhar",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Hemanth Varadhan
Greenhorn

Joined: Jun 15, 2001
Posts: 2
Originally posted by Yugandhar:
I deployed an EJB in WebLogic5.1 and Configured the property file of the weblogic to support JSP and I created a JSP file and plased it in the dir c:\weblogic\myserver\public_html. then I can access it from the localhost:7001\myjsp.jsp. But if i want use that EJB in a JSP, I want Help where to place the Bean class (i am asking the compleate path)and where will it needs to put the jar file and also what will be the package i need to plase in the JSP file. Can any one help me (if possable with a sample code) Thanks in advance.

Hi Yugandhar
You have to deploy those EJB first,after deploying u can refer to those ejb from the jsp file just as u do from any other ckient say servlet,the client code below does the same
**********-------------***********
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
ctx = new InitialContext(ht);
Object obj = ctx.lookup("JNDIBeanNAme");
BeanHome home=(BeanHome) PortableRemoteObject.narrow(obj,BeanHome.class);
**********-------------***********
From this you can refer to the ejb,you will also have to import the following pacakages
****-------****
javax.ejb.*;
javax.rmi.RemoteException;
javax.naming.*;
****-------****
Hope this helps!
hemanth
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing an EJB into a JSP