Lunarpages Web Hosting Forum

Author Topic: Help! Java/Javascript problem getting IP addresses  (Read 1078 times)

Offline mngopher

  • Newbie
  • *
  • Posts: 1
Help! Java/Javascript problem getting IP addresses
« on: October 20, 2004, 07:43:48 AM »
Hopefully someone can help me on this, but I have a site hosted by lunarpages (html and jsps).  I know java and javascript, but have the following question...

I'm trying to get a person's IP address that hits my site.  And I have the following section of test code that ISN'T working (tried both as an html and jsp page):
=================
<html>
   <%@page import="java.net.*,java.net.InetAddress.*"%>
   <body>
      <form name="frmTest">
      </form>
<script>
   var ip = new java.net.InetAddress.getLocalHost();
   var ipStr = new java.lang.String(ip);
   document.writeln(ipStr.substring(ipStr.indexOf("/")+1));
</script>   
   </body>
</html>
=================

In contacting Lunarpage support, they said I WOULDN'T need to upload any java standard library/classes to my specific site directory (putting under WEB-INF).  Can anyone help ID why the above code isn't working...or what I need to do to get that basic functionality to work?!  Thanks much!