JSP obtains the browser and operating system information of the client.

Source: Internet
Author: User

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 ")
Send another red packet
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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.