aspose file tools*
The moose likes Distributed Java and the fly likes Applet to Servlet Communication with RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Applet to Servlet Communication with RMI" Watch "Applet to Servlet Communication with RMI" New topic
Author

Applet to Servlet Communication with RMI

Jody Seigle
Greenhorn

Joined: Sep 29, 2000
Posts: 24
I'm attempting to convert an Corba application to use Applet - Servlet Communication using RMI. I've found a few references on the web but they all seem to be outdated so I just want to check the information I've gathered with the group since I've never done RMI before.
I'm assuming there needs to be some sort of Naming Service that the applet can use to get an object reference to the servlet. And this is the RMI registry?
As far as I understand the basic sequence of events is to start the RMI registry, then run the Servlet from the command line which will bind itself to the RMI registry. The start the webserver which will enable all the servlets for use. Once the applet is run, it will use the webserver hostname and port number to get a reference to the RMI registry and then resolve the servlet object using it's name that it was bound with?
Once it has the proxy object reference to the servlet it can just call the methods defined in the RMI interface much like CORBA.
Is this correct and the current way to do things?
I've also looked into a few other means of applet-servlet communication but it's my understanding that they'll be more complex since I have about 20 IDL methods with fairly complex objects as method parameters and return values. Are any of these other methods in fact easier than RMI?
Thanks,
Jody
raimondas zemaitis
Ranch Hand

Joined: Feb 23, 2001
Posts: 104
Why you want to go with RMI when you can do simple HTTP from applet to servlet ?
With RMI things are trickier, esp. if some of the parties (clien or server or both) are behind a firewall. And your sequence isn't correct actually.
Simplified:
Servlet has to extend UnicastRemoteObject and implement Remote, you have to start RMI registry, make it listen some port and bind servlet there, your applet has to know what host and which port RMI registry is running at, connect and get server stub. Then it can invoke remote methods.
Jody Seigle
Greenhorn

Joined: Sep 29, 2000
Posts: 24
I was initially wanting to use RMI because I have a complicated IDL that I'm trying to convert. With 20+ methods, using a variety of custom Object input and outputs.
It's going to be a lot of work to marshall and unmarshall the data using HTTP tunnelling as far as I can tell, but from what I've now found this is going to be my best option (due to restrictions on RMI, and the speed of operation).
Also, as far as I can tell your sequence is the exact same as what I wrote. Although I have found that instead of running the servlet from the command line to bind it to the RMI registry, you could also ensure an HTTP request activates it before allowing the applet to connect. (This is a danger however.)
-- Jody
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet to Servlet Communication with RMI