Java获取客户端代码大全
System
out
println(request
getHeaderNames()); //
返回所有request header的名字
结果集是一个enumeration(枚举)类的实例
String agent = requestgetHeader(useragent);
Systemoutprintln(agent);
StringTokenizer st = new StringTokenizer(agent;);
stnextToken();
//得到用户的浏览器名
String userbrowser = stnextToken();
Systemoutprintln(userbrowser);
//得到用户的操作系统名
String useros = stnextToken();
Systemoutprintln(useros);
//取得本机的信息也可以这样
//操作系统信息
Systemoutprintln(SystemgetProperty(osname)); //win竟然是win xp?
Systemoutprintln(SystemgetProperty(osversion));
Systemoutprintln(SystemgetProperty(osarch));
//浏览器
Systemoutprintln(requestgetHeader(useragent));
//再送个红包
Systemoutprintln(requestgetHeader(useragent)); //返回客户端浏览器的版本号类型
Systemoutprintln(requestgetMethod()); //获得客户端向服务器端传送数据的方法有getpostput等类型
Systemoutprintln(requestgetRequestURI()); //获得发出请求字符串的客户端地址
Systemoutprintln(requestgetServletPath()); //获得客户端所请求的脚本文件的文件路径
Systemoutprintln(requestgetServerName()); //获得服务器的名字
Systemoutprintln(requestgetServerPort()); //获得服务器的端口号
Systemoutprintln(requestgetRemoteAddr()); //获得客户端的ip地址
Systemoutprintln(requestgetRemoteHost()); //获得客户端电脑的名字若失败则返回客户端电脑的ip地址
Systemoutprintln(requestgetProtocol()); //
Systemoutprintln(requestgetHeaderNames()); //返回所有request header的名字结果集是一个enumeration(枚举)类的实例
Systemoutprintln(Protocol: + requestgetProtocol());
Systemoutprintln(Scheme: + requestgetScheme());
Systemoutprintln(Server Name: + requestgetServerName() );
Systemoutprintln(Server Port: + requestgetServerPort());
Systemoutprintln(Protocol: + requestgetProtocol());
Systemoutprintln(Server Info: + getServletConfig()getServletContext()getServerInfo());
Systemoutprintln(Remote Addr: + requestgetRemoteAddr());
Systemoutprintln(Remote Host: + requestgetRemoteHost());
Systemoutprintln(Character Encoding: + requestgetCharacterEncoding());
Systemoutprintln(Content Length: + requestgetContentLength());
Systemoutprintln(Content Type: + requestgetContentType());
Systemoutprintln(Auth Type: + requestgetAuthType());
Systemoutprintln(HTTP Method: + requestgetMethod());
Systemoutprintln(Path Info: + requestgetPathInfo());
Systemoutprintln(Path Trans: + requestgetPathTranslated());
Systemoutprintln(Query String: + requestgetQueryString());
Systemoutprintln(Remote User: + requestgetRemoteUser());
Systemoutprintln(Session Id: + requestgetRequestedSessionId());
Systemoutprintln(Request URI: + requestgetRequestURI());
Systemoutprintln(Servlet Path: + requestgetServletPath());
Systemoutprintln(Accept: + requestgetHeader(Accept));
Systemoutprintln(Host: + requestgetHeader(Host));
Systemoutprintln(Referer : + requestgetHeader(Referer));
Systemoutprintln(AcceptLanguage : + requestgetHeader(AcceptLanguage));
Systemoutprintln(AcceptEncoding : + requestgetHeader(AcceptEncoding));
Systemoutprintln(UserAgent : + requestgetHeader(UserAgent));
Systemoutprintln(Connection : + requestgetHeader(Connection));
Systemoutprintln(Cookie : + requestgetHeader(Cookie));
Systemoutprintln(Created : + sessiongetCreationTime());