The default RMI socket factory will automatically attempt to tunnel over HTTP when more straightforward ways of connecting fail. You don’t need to change the server or the client code. Instead, you simply need to make sure that a third server, which forwards the requests, has been installed and everything is configured correctly. Since all the code for this server is readily available, you may think that using HTTP tunneling boils down to an exercise in configuring your application. For the most part, this is true. In many cases, using HTTP tunneling boils down to installing the software and making sure all the servers are available. However, sometimes you will need to modify the tunneling mechanism. At this point, it is helpful to observe that the HTTP tunneling mechanism naturally divides into three parts:
Posts a request to the web server
Forwards the request to the RMI server’s socket, preserving the HTTP structure of the client post
Automatically handles the HTTP post, in addition to ordinary JRMP commands
These three parts can change independently. The client will automatically post to the web server if it cannot reach the RMI server directly. This will happen regardless of whether the servlet performing the tunneling is Sun’s implementation or a custom version you wrote. Similarly, the RMI server will accept either JRMP method invocations or HTTP posts, whether or not they came from a servlet doing HTTP tunneling ...