Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get the browser and operating system information of the client in JSP

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about JSP how to get client browser and operating system information. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Getting client browser and operating system information from JSP is not difficult, so let's get started.

string agent = request.getheader("user-agent");

stringtokenizer st = new stringtokenizer(agent,";");

st.nexttoken();

JSP gets the browser name of the user

string userbrowser = st.nexttoken();

JSP gets the operating system name of the user

string useros = st.nexttoken();

The local information can also be obtained as follows:

◆JSP to get the operating system information of the client

system.getproperty("os.name"); //win2003 is win xp?

system.getproperty("os.version");

system.getproperty("os.arch");

◆ Get client browser information from JSP:

request.getheader("user-agent") Returns the version number and type of the client browser

getheader(string name): Get the header information of the transfer file defined by http protocol,

request. getmethod(): Get the client to send data to the server side of the method have get, post, put and other types

request. getrequesturi(): Gets the address of the client that issued the request string

request. getservletpath(): Gets the file path of the script file requested by the client

request. getservername(): Gets the name of the server

request.getserverport(): Get the port number of the server

request. geremoteaddr (): Get IP address of client

request. geremotehost (): Get the name of the client computer, if failed, return the IP address of the client computer

request. getheaders (): Returns the names of all request headers, the result set is an instance of the enumeration class

request.getheaders(string name): Returns all values of the request header for the specified name, the result set is an instance of the enumeration class

JSP to obtain client browser and operating system information in the actual development is an important link, then the various functions of the call will help you achieve the goal, now you are more understand their meaning?

Thank you for reading! About "JSP how to get client browser and operating system information" this article is shared here, I hope the above content can be of some help to everyone, so that we can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report