How to get client browser and operating system information in JSP

xiaoxiao2021-03-06  64

String Agent = Request.getHeader ("User-Agent"); StringTokenizer ST = New StringTokenizer (Agent, ";"); st.nextToken (); // Get user browser name string userbrowser = st.nextToken (); // Get the user's operating system name string useros = st.nextToken (); obtain the information of this unit can also be the case: Operating system information system.getProperty ("os.name"); // Win2003 is Win XP? System.getProperty; System.GetProperty ("os.arch"); browser: Request.getHeader ("user-agent") and send a red envelope Request.getHeader ("User-agent") Return to customers End browser version number, type

GetHeader (String Name): Get the transfer file header information defined by the HTTP protocol,

Request. getMethod (): Getting the client to send data to the server, there is GET, POST, PUT and other types.

Request. getRequesturi (): Get the client address of the issuance request string

Request. getServletPath (): File path for obtaining the script file requested by the client

Request. getServerName (): Get the name of the server

Request.getServerPort (): Get the port number of the server

Request.GetRemoteAddr (): Get the IP address of the client

Request.getRemotehost (): Get the name of the client computer, if it fails, return to the client computer IP address

Request.GetProtocol ():

Request.getHeadernages (): Returns the name of all Request Header, the result set is an Enumeration instance

Request.getHeaders: Returns all values ​​of the Request Header of the specified name, the result set is an instance of an Enumeration class

转载请注明原文地址:https://www.9cbs.com/read-89815.html

New Post(0)