你要用IP这种方式访问
http://10.41.192.1:8080/test.jsp

解决方案 »

  1.   

    request.getServerName();这个方法得到的也是服务器的IP地址。
      

  2.   

    InetAddress.getLocalHost().getHostName());
    InetAddress.getLocalHost().getHostAddress());
    这两个均没错,分别返回本地的机器名称以及ip至于InetAddress host_name = InetAddress.getByName(ip_address);
    就一点不一样了,请打开C:\WINNT\system32\drivers\etc\hosts(我的机器是win2k),getByName()函数其实就是从hosts文件读取,有没有对应的<ip,name>映射,如果有,就直接返回,如果没有,才会建立连接去取.
      

  3.   

    InetAddress localhost = InetAddress.getLocalHost();
    System.out.println(localhost.getHostName());
      

  4.   

    InetAddress.getLocalHost().getHostName());
    InetAddress.getLocalHost().getHostAddress());刚测试一下,发现这个得到的是服务器端的。
      

  5.   

    用request.getRemoteAddr();返回发送请求的客户的IP地址
    用request.getRemoteHost();返回发送请求的客户主机的全名,如果不能确定主机名就返回客户的IP地址。
      

  6.   

    <%
    dim i
    for each i in request.ServerVariables
    response.Write("<strong>"&i&"</strong> :<br/>")
    response.Write(request.ServerVariables(i) & "<br/>")
    next
    response.End()
    %>