Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Applets access EJB's??

Status
Not open for further replies.

dot001

Programmer
May 17, 2001
1
0
0
US
the online tutorial at Sun ( ) shows me how to setup a nice little example with bolth a web client, and a web component. I've been trying to add the functionality of the web client to an applet which I will package with the web component. When I try to add the class file It put's it in a subdirectory call WEB-INF\classes. It is treating it like a servlet. I can manually copy it to the contex root directory, and then my index.jsp page can load it, but on the declartation of the Context initial. The applet stops functioning. Is this possible?
here is what I have included.
import java.awt.*;
import java.applet.*;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
I've copied the javax classes into the context root as well.



Here is the code I would like to put in side of my applet.

try {
Context initial = new InitialContext();
Object objref = initial.lookup("java:comp/env/ejb/SimpleConverter");

ConverterHome home =
(ConverterHome)PortableRemoteObject.narrow(objref,
ConverterHome.class);// cast to converter home

Converter currencyConverter = home.create();// an instance of the Converter class
//double amount = currencyConverter.ddollarToYen(100.00);
System.out.println(currencyConverter.ddollarToYen("asdf", "fdsa"));
currencyConverter.remove();

//amount = currencyConverter.yenToEuro(100.00);
//System.out.println(String.valueOf(amount));

} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
Please tell me if it's possible and give me pointers if anyone has experience thanx so much,
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top