1.) You can have multiple servers and a single client on one machine - just bind the different servers under different names in the registry, and have the client connect to each of the servers using different names for each. You may want to use the Naming.list("rmi://localhost") method to get back a String array of all names bound in the registry to help the client find servers.
2.) When you first connect to the remote "server" object you get back a stub - this is basically a "remote reference" to the object. What you get back as a return value from a method depends on what type the return value is. If a return value is Serializable you get back a copy of that object on the client. If a return value is Remote you get back a stub to the remote object on the server - which behaves just like the stub to your original "server" object.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Apr 15, 2005
can i write rmi client in servlet or jsp page. Where do i place my policy file then and what policy entry do i have to add in.
Yes, you can make RMI calls from a servlet or JSP page (though you may want to do something so you don't have to constantly call Naming.lookup() and get a reference - that can take a while. It's easy to stick the stub reference into the application or session contexts using listeners.)
There are some pointers on setting security managers and policy files in this question to JGuru, but a lot is dependent on the app server you are using.