手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>Java技术>列表

实例:JSP中获取客户端的浏览器和操作系统信息

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

string agent = request.getheader("user-agent");
stringtokenizer st = new stringtokenizer(agent,";");
st.nexttoken();
//得到用户的浏览器名
string userbrowser = st.nexttoken();
//得到用户的操作系统名
string useros = st.nexttoken();

取得本机的信息也可以这样:

操作系统信息

system.getproperty("os.name"); //win2003竟然是win xp?
system.getproperty("os.version");
system.getproperty("os.arch");

浏览器:

request.getheader("user-agent")

再送个红包

request.getheader(“user-agent”)返回客户端浏览器的版本号、类型
getheader(string name):获得http协议定义的传送文件头信息,
request. getmethod():获得客户端向服务器端传送数据的方法有get、post、put等类型
request. getrequesturi():获得发出请求字符串的客户端地址
request. getservletpath():获得客户端所请求的脚本文件的文件路径
request. getservername():获得服务器的名字
request.getserverport():获得服务器的端口号
request.getremoteaddr():获得客户端的ip地址
request.getremotehost():获得客户端电脑的名字,若失败,则返回客户端电脑的ip地址
request.getprotocol():
request.getheadernames():返回所有request header的名字,结果集是一个enumeration(枚举)类的实例
request.getheaders(string name):返回指定名字的request header的所有值,结果集是一个enumeration(枚举)类的实例

关键词:
【推荐给好友】【关闭】
最新五条评论
查看全部评论
评论总数 0 条
您的评论
用户名: 新注册) 密 码: 匿名:
·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!