10/24: JS(JavaScript)で取得できるクライアント情報
JS(JavaScript)で取得できるクライアント情報、そこからアクセス解析の仕組みを考えてみる
function functest() { var strwork; var jsDate; jsDate = new Date(); strwork = "JSDATE : " + jsDate.getFullYear() + "/" + jsDate.getMonth()+1 + "/" + jsDate.getDate() + " " + jsDate.getHours() + ":" + jsDate.getMinutes() + ":" + jsDate.getSeconds() + "\n"; strwork = strwork + "HOST : " + location.host + "\n"; strwork = strwork + "HOSTNAME : " + location.hostname + "\n"; strwork = strwork + "PORT : " + location.port + "\n"; strwork = strwork + "PROTOCOL : " + location.protocol + "\n"; strwork = strwork + "HASH : " + location.hash + "\n"; strwork = strwork + "SEARCH : " + location.search + "\n"; strwork = strwork + "REQUEST : " + location.pathname + "\n"; strwork = strwork + "CODE : " + navigator.appCodeName + "\n"; strwork = strwork + "BROWSER : " + navigator.appName + "\n"; strwork = strwork + "VERSION : " + navigator.appVersion + "\n"; strwork = strwork + "LANG : " + navigator.language + "\n"; strwork = strwork + "PLATFORM : " + navigator.platform + "\n"; strwork = strwork + "USERAGENT: " + navigator.userAgent + "\n"; strwork = strwork + "REFERER : " + document.referrer + "\n"; strwork = strwork + "DOMAIN : " + document.domain + "\n"; strwork = strwork + "SCREEN.W : " + screen.width + "\n"; strwork = strwork + "SCREEN.H : " + screen.height + "\n"; if (screen.colorDepth==8) { strwork = strwork + "SCREEN.COL: " + screen.colorDepth + "Bit\n"; } else { strwork = strwork + "SCREEN.COL: " + screen.colorDepth + "Bit\n"; } alert(strwork); }
RADKRAFT: サーブレット/JSPのヘッダ情報の取得方法
<%@ page language="java" contentType="text/html;charset=Shift_JIS" %> <html><body> クライアントのホスト名(REMOTE_HOST)=<%= request.getRemoteHost() %><br> クライアントのIPアドレス(REMOTE_ADDR)=<%= request.getRemoteAddr() %><br> 要求されたURL(1)=<%= request.getRequestURI() %><br> 要求されたURL(2)=<%= request.getRequestURL().toString() %><br> サーブレットパス=<%= request.getServletPath() %><br> サーバ上のパス=<%= getServletContext().getRealPath(request.getServletPath()) %><br> 要求されたURLのパス(PATH_INFO)=<%= request.getPathInfo() %><br> 要求されたURLのサーバ上のパス(PATH_TRANSLATED)=<%= request.getPathTranslated() %><br> 要求のメソッド=<%= request.getMethod() %><br> 参照元のURL=<%= request.getHeader("Referer") %><br> プロトコル(HTTP)=<%= request.getProtocol() %><br> ポート番号=<%= String.valueOf(request.getServerPort()) %><br> <br> ファイルconfig.xmlのパス=<%= getServletContext().getRealPath("/config.xml") %><br> ファイルconfig.xmlのURL=<%= request.getContextPath() + "/config.xml" %><br> </body></html>