jsp 获取客户端的浏览器和操作系统信息
所属分类:
网络编程 / JSP编程
阅读数:
1458
收藏 0赞 0分享
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(枚举)类的实例
Java Web实现的基本MVC实例分析
这篇文章主要介绍了Java Web实现的基本MVC,以完整实例形式较为详细的分析了JSP实现MVC架构的具体步骤与相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
收藏 0赞 0分享
jsp中调用java代码小结
大多数情况下, jsp 文档的大部分由静态文本(html)构成, 为处理该页面而创建的 servlet 只是将它们原封不动的传递给客户端
收藏 0赞 0分享
struts2中一个表单中提交多个请求的例子(多个提交按钮)
在很多Web应用中,为了完成不同的工作,一个HTML form标签中可能有两个或多个submit按钮,Struts2中提供了另外一种方法,使得无需要配置可以在同一个action类中执行不同的方法(默认执行的是execute方法)
收藏 0赞 0分享
servlet中session简介和使用例子
在servlet中,session是封装在javax.servlet.http.HttpSession这个接口中的,这个接口是构建在cookie或者URL重写的基础上,要得到一个HttpSession的实例,就可以通过HttpServletRequest的getSession()
收藏 0赞 0分享
查看更多