jsp gets the client's browser and operating system information

  • 2020-05-10 18:37:51
  • OfStack

string agent = request.getheader("user-agent");
stringtokenizer st = new stringtokenizer(agent,";");
st.nexttoken();
// get the user's browser name
string userbrowser = st.nexttoken();
// get the user's operating system name
string useros = st.nexttoken();
Getting the information of the machine can also be done like this:
Operating system information
system. getproperty (" os name "); //win2003 is win xp?
system.getproperty("os.version");
system.getproperty("os.arch");
� � :
request.getheader("user-agent")
Give me another red envelope
request.getheader (" user-agent ") returns the version number and type of the client browser
getheader(string name) : get the transfer header information defined by the http protocol,
request.getmethod () : the methods to get data from the client to the server are get, post, put, and so on
request.getrequesturi () : gets the client address of the originating 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 () : gets the port number of the server
request.getremoteaddr () : get the ip address of the client
request.getremotehost () : gets the name of the client computer and, if that fails, returns the ip address of the client computer
request. getprotocol () :
request.getheadernames () : returns the names of all request header, and the result set is an instance of one enumeration (enumeration) class
request.getheaders (string name) : returns all values of request header with the specified name, and the result set is an instance of an enumeration (enumeration) class

Related articles: