HTTP tunneling is enabled by default in RMI. Using HTTP tunneling doesn’t require any code changes on either the client or the server. Instead, all that is required is that a web server be installed and configured. The complete list of steps to accomplish this for the bank example are:
Install the web server. I chose to install JavaWebServer because, as far as I can tell, it is the easiest web server to install and configure.
Add the servlet to the web server. This
boils down to somehow telling the web server that
URLs beginning with /cgi-bin/java-rmi.cgi are
mapped to the servlet handling HTTP tunneling (in
Test to make sure everything works.
Testing is sometimes a little tricky.
Developers often don’t have a firewall readily
available in their development environment. To
help get around this difficulty, Sun has provided
a socket factory class,
Factory, which only uses
HTTP tunneling when attempting to connect to a
server. That is, of the five ways a default socket
factory can connect to a server, instances of
will use only the final two. Namely:
It attempts to connect on port 80 of the server machine and send the request to a URL beginning with /cgi-bin/java-rmi.cgi. The interpretation of this URL is that the request will be forwarded to a program that interprets the HTTP request and forwards it, as an HTTP request, to ...