String agent = request. getheader ("User-Agent ");
Stringtokenizer ST = new stringtokenizer (agent ,";");
St. nexttoken ();
// Obtain the user's browser name
String userbrowser = ST. nexttoken ();
// Obtain the user's OS name
String useros = ST. nexttoken ();
You can also obtain the information of the local machine as follows:
Operating System Information
System. getproperty ("OS. Name"); // win2003 is actually Win XP?
System. getproperty ("OS. Version ");
System. getproperty ("OS. Arch ");
Scanner:
Request. getheader ("User-Agent ")
Request. getheader ("User-Agent") returns the version and type of the client browser.
Getheader (string name): Get the header information defined by the HTTP protocol,
Request. getmethod (): The methods used to obtain data transmitted from the client to the server include get, post, put, and so on.
Request. getrequesturi (): obtains the client address of the request string.
Request. getservletpath (): Obtain the path of the script file requested by the client.
Request. getservername (): Get the server name
Request. getserverport (): Get the server port number
Request. getremoteaddr (): Obtain the Client IP Address
Request. getremotehost (): obtains the name of the client computer. If the name fails, the IP address of the client computer is returned.
Request. getprotocol ():
Request. getheadernames (): returns the names of all request headers. The result set is an instance of the enumeration (enumeration) class.
Request. getheaders (string name): returns all the values of the request header with the specified name. The result set is an instance of the enumeration (enumeration) class.