See the
JGuru RMI tutorial, specifically the section entitled "Firewall Issues" to get a good understanding of what is going on. Then check out
Sun's RMI FAQ, specifically the "Networking" section that deals with workarounds to firewalls and questions about using the cgi-script versus a
servlet.