java web 获取客户端的计算机名称

caonimazige 2012-06-11 05:51:18
各位帮帮忙,我想获取客户端的计算机名称,怎么获取,不要说用request.RemoteHost()这个获取外网的计算机名称是获取的总是ip,不知道为什么,网上我找了找说是js可以而且我也成功获取到了。但是的主动去设置ie的安全设置,这样不行。求各位大侠给点别的意见!或者思路。
...全文
9520 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
爽蝈蝈 2015-02-25
  • 打赏
  • 举报
回复
修改tomcat conf 下server.xml 把<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/> 改成<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" enableLookups="ture" redirectPort="8443"/>
ithoney 2012-06-15
  • 打赏
  • 举报
回复
弱弱说一下,那个计算机是山寨的或组装的,你怎么获得名字?
苹果树9 2012-06-15
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
引用 7 楼 的回复:

不可能的,你得不到!


顶顶。
[/Quote]

这是关系到安全隐私的问题,不可能的,让楼主得到的。
caonimazige 2012-06-15
  • 打赏
  • 举报
回复
这个还真不知道。我只是能用js获取,但是的用户手动改,ie的安全设置。
bea_java 2012-06-13
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]

不可能的,你得不到!
[/Quote]

顶顶。
linfssay 2012-06-13
  • 打赏
  • 举报
回复
关注中。。。
局域网中试过, 外网没用过
caonimazige 2012-06-13
  • 打赏
  • 举报
回复
真的没有别的方法了?
  • 打赏
  • 举报
回复
不可能的,你得不到!
五哥 2012-06-12
  • 打赏
  • 举报
回复
package com;


import java.io.IOException;
import java.net.InetAddress;
import java.util.Enumeration;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@SuppressWarnings("serial")
public class HeaderServlet extends HttpServlet {


@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
InetAddress.getLocalHost().toString();
String auth = request.getHeader("Authorization");
if (auth == null) {
response.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM");
response.flushBuffer();
return;
}
if (auth.startsWith("NTLM ")) {
byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth
.substring(5));
int off = 0, length, offset;
if (msg[8] == 1) {
byte z = 0;
byte[] msg1 = { (byte) 'N', (byte) 'T', (byte) 'L', (byte) 'M',
(byte) 'S', (byte) 'S', (byte) 'P', z, (byte) 2, z, z,
z, z, z, z, z, (byte) 40, z, z, z, (byte) 1,
(byte) 130, z, z, z, (byte) 2, (byte) 2, (byte) 2, z,
z, z, z, z, z, z, z, z, z, z, z };
response.setHeader("WWW-Authenticate", "NTLM "
+ new sun.misc.BASE64Encoder().encodeBuffer(msg1));
response.sendError(response.SC_UNAUTHORIZED);
return;
} else if (msg[8] == 3) {
off = 30;


length = msg[off + 17] * 256 + msg[off + 16];
offset = msg[off + 19] * 256 + msg[off + 18];
String remoteHost = new String(msg, offset, length);


length = msg[off + 1] * 256 + msg[off];
offset = msg[off + 3] * 256 + msg[off + 2];
String domain = new String(msg, offset, length);


length = msg[off + 9] * 256 + msg[off + 8];
offset = msg[off + 11] * 256 + msg[off + 10];
String username = new String(msg, offset, length);


System.out.println(username);
System.out.println(domain);
System.out.println(remoteHost);
}
}
}


}
wflyxiaonian 2012-06-12
  • 打赏
  • 举报
回复
取不到吧 设计安全问题 插件开发去获取也许可以
caonimazige 2012-06-12
  • 打赏
  • 举报
回复
楼上的这个不是,我要的而是计算机名称. 但还是谢谢。坐等大神来解答!!!
芒果 2012-06-11
  • 打赏
  • 举报
回复
<%@ page contentType="text/html;charset=GBk" import="java.util.*"%>
<html>
<head>
<title>请求信息</title>
</head>
<body>
<p>使用request对象的方法获取信息</p>

<%
//服务器
String localName=request.getLocalName();
String serverName = request.getServerName();
String localAddr=request.getLocalAddr();
int localPort=request.getLocalPort();
int serverPort = request.getServerPort();%>

<b>服务器</b>:<%= localName %><br/>
<b>服务器端IP</b>:<%= localAddr %><br/>
<b>服务器端口</b>:<%= localPort %><p/>
//客户端信息
String remoteHost=request.getRemoteHost();
String remoteAddr=request.getRemoteAddr();
int remotePort=request.getRemotePort();%>
<b>浏览器端</b>:<%= remoteHost %><br/>
<b>浏览器端IP是</b>:<%= remoteAddr %><br/>
<b>浏览器端口</b>:<%= remotePort %><p/>


<%
//协议相关
String pro=request.getProtocol();
String pro1=request.getScheme();
int len=request.getContentLength();
String type=request.getContentType();
String charEncode=request.getCharacterEncoding();
%>
<b>协议版本</b>:<%= pro %><br/>
<b>协议</b>:<%= pro1 %><br/>
<b>数据内容长度</b>:<%= len %><br/>
<b>数据类型</b>:<%= type %><br/>
<b>字符编码方式</b>:<%= charEncode %><p/>

</body>
</html>
芒果 2012-06-11
  • 打赏
  • 举报
回复
request.RemoteHost()方式去攻取是通过客户端发上来的报文头上下文得到的,好像是没有计算机名称这个参数。关注中。。。

81,092

社区成员

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

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