熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

Java獲取客戶端代碼大全

2013-11-23 19:29:53  來源: Java核心技術 
    Java獲取客戶端代碼大全Systemoutprintln(requestgetHeaderNames()); //返回所有request header的名字結果集是一個enumeration(枚舉)類的實例
    String agent = requestgetHeader(useragent);
    Systemoutprintln(agent);
    StringTokenizer st = new StringTokenizer(agent;);
    stnextToken();
    //得到用戶的浏覽器名
    String userbrowser = stnextToken();
    Systemoutprintln(userbrowser);
    //得到用戶的操作系統名
    String useros = stnextToken();
    Systemoutprintln(useros);
    //取得本機的信息也可以這樣
    //操作系統信息
    Systemoutprintln(SystemgetProperty(osname)); //win竟然是win xp?
    Systemoutprintln(SystemgetProperty(osversion));
    Systemoutprintln(SystemgetProperty(osarch));
    //浏覽器
    Systemoutprintln(requestgetHeader(useragent));
    //再送個紅包
    Systemoutprintln(requestgetHeader(useragent)); //返回客戶端浏覽器的版本號類型
    Systemoutprintln(requestgetMethod()); //獲得客戶端向服務器端傳送數據的方法有getpostput等類型
    Systemoutprintln(requestgetRequestURI()); //獲得發出請求字符串的客戶端地址
    Systemoutprintln(requestgetServletPath()); //獲得客戶端所請求的腳本文件的文件路徑
    Systemoutprintln(requestgetServerName()); //獲得服務器的名字
    Systemoutprintln(requestgetServerPort()); //獲得服務器的端口號
    Systemoutprintln(requestgetRemoteAddr()); //獲得客戶端的ip地址
    Systemoutprintln(requestgetRemoteHost()); //獲得客戶端電腦的名字若失敗則返回客戶端電腦的ip地址
    Systemoutprintln(requestgetProtocol()); //
    Systemoutprintln(requestgetHeaderNames()); //返回所有request header的名字結果集是一個enumeration(枚舉)類的實例
    Systemoutprintln(Protocol: + requestgetProtocol());
    Systemoutprintln(Scheme: + requestgetScheme());
    Systemoutprintln(Server Name: + requestgetServerName() );
    Systemoutprintln(Server Port: + requestgetServerPort());
    Systemoutprintln(Protocol: + requestgetProtocol());
    Systemoutprintln(Server Info: + getServletConfig()getServletContext()getServerInfo());
    Systemoutprintln(Remote Addr: + requestgetRemoteAddr());
    Systemoutprintln(Remote Host: + requestgetRemoteHost());
    Systemoutprintln(Character Encoding: + requestgetCharacterEncoding());
    Systemoutprintln(Content Length: + requestgetContentLength());
    Systemoutprintln(Content Type: + requestgetContentType());
    Systemoutprintln(Auth Type: + requestgetAuthType());
    Systemoutprintln(HTTP Method: + requestgetMethod());
    Systemoutprintln(Path Info: + requestgetPathInfo());
    Systemoutprintln(Path Trans: + requestgetPathTranslated());
    Systemoutprintln(Query String: + requestgetQueryString());
    Systemoutprintln(Remote User: + requestgetRemoteUser());
    Systemoutprintln(Session Id: + requestgetRequestedSessionId());
    Systemoutprintln(Request URI: + requestgetRequestURI());
    Systemoutprintln(Servlet Path: + requestgetServletPath());
    Systemoutprintln(Accept: + requestgetHeader(Accept));
    Systemoutprintln(Host: + requestgetHeader(Host));
    Systemoutprintln(Referer : + requestgetHeader(Referer));
    Systemoutprintln(AcceptLanguage : + requestgetHeader(AcceptLanguage));
    Systemoutprintln(AcceptEncoding : + requestgetHeader(AcceptEncoding));
    Systemoutprintln(UserAgent : + requestgetHeader(UserAgent));
    Systemoutprintln(Connection : + requestgetHeader(Connection));
    Systemoutprintln(Cookie : + requestgetHeader(Cookie));
    Systemoutprintln(Created : + sessiongetCreationTime());
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26966.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.