Java Get customer service information (System, browser, etc.)

Source: Internet
Author: User
Tags session id

String Agent = Request.getheader ("user-agent");
SYSTEM.OUT.PRINTLN (agent);
StringTokenizer st = new StringTokenizer (agent, ";");
St.nexttoken ();
String Userbrowser = St.nexttoken ();
System.out.println (Userbrowser);
String Useros = St.nexttoken ();
System.out.println (Useros);
System.out.println (System.getproperty ("Os.name")); Win2003 unexpectedly is Win XP?
System.out.println (System.getproperty ("os.version"));
System.out.println (System.getproperty ("Os.arch"));
System.out.println (Request.getheader ("user-agent")); Returns the version number, type of the client browser
System.out.println (Request.getmethod ()); : Get, post, put, etc. for client to send data to server side
System.out.println (Request.getrequesturi ()); : Gets the client address that issued the request string
System.out.println (Request.getservletpath ()); : Gets the file path of the script file requested by the client
System.out.println (Request.getservername ()); : Get the name of the server
System.out.println (Request.getserverport ()); : Gets the port number of the server
System.out.println (Request.getremoteaddr ()); : Obtain the IP address of the client
System.out.println (Request.getremotehost ()); : Gets the name of the client computer and, if it fails, returns the IP address of the client computer
System.out.println (Request.getprotocol ()); :
System.out.println (Request.getheadernames ()); : Returns the name of all request headers, which is an instance of the enumeration (enum) class
System.out.println ("Protocol:" + request.getprotocol ());
System.out.println ("Scheme:" + request.getscheme ());
System.out.println ("Server Name:" + request.getservername ());
System.out.println ("Server Port:" + request.getserverport ());
System.out.println ("Protocol:" + request.getprotocol ());
System.out.println ("Server Info:" + getservletconfig (). Getservletcontext (). Getserverinfo ());
System.out.println ("Remote Addr:" + request.getremoteaddr ());
System.out.println ("Remote Host:" + request.getremotehost ());
System.out.println ("Character Encoding:" + request.getcharacterencoding ());
System.out.println ("Content Length:" + request.getcontentlength ());
System.out.println ("Content Type:" + request.getcontenttype ());
System.out.println ("Auth Type:" + request.getauthtype ());
System.out.println ("HTTP Method:" + Request.getmethod ());
System.out.println ("Path Info:" + request.getpathinfo ());
System.out.println ("Path Trans:" + request.getpathtranslated ());
System.out.println ("Query String:" + request.getquerystring ());
System.out.println ("Remote User:" + request.getremoteuser ());
System.out.println ("Session Id:" + Request.getrequestedsessionid ());
System.out.println ("Request URI:" + Request.getrequesturi ());
System.out.println ("Servlet Path:" + Request.getservletpath ());
System.out.println ("Accept:" + request.getheader ("accept"));
System.out.println ("Host:" + Request.getheader ("host"));
System.out.println ("Referer:" + request.getheader ("Referer"));
System.out.println ("Accept-language:" + request.getheader ("Accept-language"));
System.out.println ("accept-encoding:" + request.getheader ("accept-encoding"));
System.out.println ("user-agent:" + request.getheader ("user-agent"));
System.out.println ("Connection:" + request.getheader ("Connection"));
System.out.println ("Cookie:" + request.getheader ("cookie"));

Get the value of User-agent

Use request.header["User-agent" in ASP.) to get the user Agent of the browser, you can also use the request.useragent to obtain;
Java uses Request.getheader ("User-agent") to obtain;
PHP in the appropriate use: $_server[http_user_agent];

JS in the use of navigator.useragent to obtain (the client often use it to do browser-compatible).

Java Get customer service information (System, browser, etc.)

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.