在jsp中,怎样根据IP地址得到域名??

longpc 2003-06-09 02:57:06
RT
...全文
380 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Chuff 2003-06-10
  • 打赏
  • 举报
回复
关注
yangjuanli 2003-06-09
  • 打赏
  • 举报
回复
一个IP可以有两个或多个域名的。
凋零的老树 2003-06-09
  • 打赏
  • 举报
回复
一个IP有可能有两个域名吗?
ZeroC 2003-06-09
  • 打赏
  • 举报
回复
域名-〉ip
easy!
ip->域名
知道了告诉我一声!:)好象不太可能
moonyuezhao 2003-06-09
  • 打赏
  • 举报
回复
import java.io.*;

/**
* @author YueZhao
*/
public class PingTest {
public static void main(String[] args){
Runtime runtime=Runtime.getRuntime();
Process process=null;
String line=null;
InputStream is=null;
InputStreamReader isr=null;
BufferedReader br=null;
String ip="192.168.0.180";
try{
process=runtime.exec("ping /a "+ip);
is=process.getInputStream();
isr=new InputStreamReader(is);
br=new BufferedReader(isr);
while((line=br.readLine())!=null){
System.out.println(line);
}
is.close();
isr.close();
br.close();
}catch(IOException e){

}
}
}
程序的输出中有域名,自己想办法解析出来就可以了。
不过在我的Linux系统上的ping 命令不支持 -a 参数!
leshui 2003-06-09
  • 打赏
  • 举报
回复
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.net.*"%>
<%
InetAddress myInetAddress;
myInetAddress=InetAddress.getByName("www.163.com");
out.println(myInetAddress);
out.println("<br>");
out.println(myInetAddress.getHostName());
out.println("<br>");
%>
只有ip的话好象还是出不来
zzhangwa 2003-06-09
  • 打赏
  • 举报
回复
request.getRemoteHost()
request.getRemoteAddr()
aleccheung 2003-06-09
  • 打赏
  • 举报
回复
java.net.InetAddress address = InetAddress.getByName(host);
out.println(address.getHostName());

request.getRemoteHost()

http://expert.csdn.net/Expert/topic/1696/1696561.xml?temp=.5453913

leshui 2003-06-09
  • 打赏
  • 举报
回复
啊。。。。。
这好象有点难度
这是域名解析的问题
知道域名查ip的话好象还可以

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧