Jsp browser access information, operating system information, Client IP address, jspip

Source: Internet
Author: User

Jsp browser access information, operating system information, Client IP address, jspip

<% String path = request. getContextPath (); String agent = request. getHeader ("User-Agent"); String browInfo [] = agent. split (";"); String realBrowser = browInfo [1]. trim (); // browser information String osInfo = System. getProperty ("OS. name "); // operating system information String ip = request. getRemoteAddr (); // Client IP address %>


How to obtain the browser and operating system information of the client in jsp

// Obtain the user's browser name String userbrowser = st. nextToken (); // obtain the user's operating system name String useros = st. nextToken (); obtain the information of the local machine as follows: Operating System Information System. getProperty ("OS. version "); System. getProperty ("OS. arch "); Browser: request. getHeader ("User-Agent") then sends a red packet request. getHeader (User-agent) returns the version number and type of the client browser getHeader (String name): Get the transfer file 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 other types of requests. getRequestURI (): Get the client address request that sends the request string. getServletPath (): Get the file path request of the script file requested by the client. getServerName (): Get the server name request. getServerPort (): Get the server port number request. getRemoteAddr (): Get the Client IP address request. getRemoteHost (): get the name of the client computer. If the source code fails, the system returns the IP address request of the client computer. getProtocol (): request. getHeaderNames (): returns the names of all request headers. The result set is an instance request of the Enumeration (Enumeration) class. getHeaders (String name): returns all values of the request header with the specified name. The result set is an instance of the Enumeration (Enumeration) class.

How to obtain the browser and operating system information of the client in jsp

// 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. version ");
System. getProperty ("OS. arch "); Response handler: request. getHeader ("User-Agent") then sends a red packet request. getHeader (User-agent) returns the client browser version number and type
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 (): Obtain the name of the client computer.
Returns the IP address of the client.
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.

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.