Instance: Getting the client's browser and operating system information in the JSP

Source: Internet
Author: User
Tags header client port number
js| Client | browser

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 ();

You can also get information about this machine:

Operating System Information

System.getproperty ("Os.name"); Win2003 unexpectedly is Win XP?
System.getproperty ("Os.version");
System.getproperty ("Os.arch");

Browser:

Request.getheader ("User-agent")

and send a red envelope.

Request.getheader ("User-agent") returns the version number, type of the client browser
GetHeader (string name): Gets the header information for the HTTP protocol definition for the delivery file.
Request. GetMethod (): Get the client to the server side of the data transfer method has get, post, put and other types
Request. Getrequesturi (): Gets the client address that issued the request string
Request. Getservletpath (): Gets the file path of 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 (): Obtain the client's IP address
Request.getremotehost (): Get the name of the client computer, if it fails, return the IP address of the client computer
Request.getprotocol ():
Request.getheadernames (): Returns the name of all request headers, and the result set is an instance of a enumeration (enumerated) class
Request.getheaders (string name): Returns all values for the request header of the specified name, and the result set is an instance of a 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.