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

Browser

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 Transfer File Header defined by http
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 Enumeration) instance of the class.
Request. getHeaders (String name): returns all request header values with the specified name,
The result set is an Enumeration) instance of the class.

Related Articles]

  • Rapid development of JSP applications using JSTL
  • Three methods to display Chinese Characters in Web programs developed by JSP
  • Session-based online user statistical analysis in JSP

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.