• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Applet to Servlet Communication with RMI

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic