java 監控 收集資料(收集中)

來源:互聯網
上載者:User

JSP根據IP段跳轉不同頁面的問題

String remoteHost = request.getRemoteHost(); 
得到ip地址,並對ip訪問進行限制:
public String getIpAddr(HttpServletRequest request) {       String ip = request.getHeader("x-forwarded-for");       if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {           ip = request.getHeader("Proxy-Client-IP");       }       if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {           ip = request.getHeader("WL-Proxy-Client-IP");       }       if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {           ip = request.getRemoteAddr();       }       return ip;   }

    js判斷使用者來路url(使用http header referer)

HTTP Header referer這玩意主要是告訴人們我是從哪兒來的,就是告訴人家我是從哪個頁面過來的,可以用於統計訪問本網站的使用者來源,也可以用來防盜鏈。擷取這個東西最好的方式是js,如果在伺服器端擷取(方法如:Request.Headers["Referer"]) 不靠譜,人家可以偽造,用js擷取最好,人家很難偽造,方法:利用js的 document.referer 方法可以準確地判斷網頁的真實來路。 目前百度統計,google ads統計,CNZZ統計,都是用的這個方法。防盜鏈也很簡單了,js裡判斷來路url如果不是本站不顯示圖片

 

 

 

 

 

在IE中用javascript做跳轉,比如用window.location.href = “http://www.google.com”; google無法取到瀏覽器請求的HTTP referrer,因為IE清空了document.referrer

而其他主流瀏覽器Firefox和Chrome都會保留referrer,這意味著IE又要享受“部長級”特殊待遇了:

view source
1 if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
2     var referLink = document.createElement('a');
3     referLink.href = url;
4     document.body.appendChild(referLink);
5     referLink.click();
6 else {
7     location.href = url;
8

}

 

 

   分析java 的抓包資訊: 可能會用到: http://blog.csdn.net/guanchanghui/article/details/1796390  編輯瀏覽器和伺服器之間的時間差: 
ASP擷取伺服器端詳細時間:<%=now()%>伺服器端年日期:<%=date()%>伺服器端年時間:<%=time()%>JS擷取瀏覽器端時間<script>today=new Date();year=today.getFullYear()month=today.getMonth()+1date=today.getDate()hh = today.getHours(); mm = today.getMinutes(); ss = today.getTime() % 60000;ss = (ss - (ss % 1000)) / 1000;  document.write (year+"-"+month+"-"+date);//年月日document.write (" ");document.write(hh+':'+mm+":"+ss);//時分秒</script>  計算網頁產生的時間差ASP擷取頁面執行時間<%dim startimestartime=timer() '頁頭代碼dim endtimeendtime=timer() '頁尾代碼response.Write("頁面執行時間 0"&FormatNumber((Endtime-Startime),5)&" 秒")%>JS擷取頁面執行時間頁頭代碼<script language=javascript>  <!--  var startTime,endTime;  var d=new Date();  startTime=d.getTime();  //--> </script> 頁尾代碼<script language=javascript>d=new Date();endTime=d.getTime();document.write ((endTime-startTime)/1000);</script>

頁面自動跳轉

先給大家一個最簡單,好用的JS調用代碼:

網頁自動跳轉JS代碼

<script type="text/java script">
    document.location.href = "http://www.txasp.com";
</script>

將裡面的http://www.txasp.com改成你自己的地址就可以了. 下面給大家介紹的是網上亂七八糟找的,綜合供大家看看.

------------------------------------------------------------------------------
不隱藏轉向之後的地址 代碼一
------------------------------------------------------------------------------ 
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title></title>
</head>
<body>
<form name=loading>
<P align=center><FONT face=Arial color=#0066ff size=2>loading...</FONT> <INPUT 
 
size=46 name=chart> <BR><INPUT 
 
size=47 name=percent>
<SCRIPT> 
var bar=0 
var line="||" 
var amount="||" 
count() 
function count(){ 
bar=bar+2 
amount =amount + line 
document.loading.chart.value=amount 
document.loading.percent.value=bar+"%" 
if (bar<99) 
{setTimeout("count()",100);} 
else 
{window.location = "將這裡改成要轉入的網址";} 
}</SCRIPT>
</P></form>
</body>
</html>
-------------------------------------------------------------------------------

不隱藏轉向之後的地址 代碼二
------------------------------------------------------------------------------- 
<html>
<body>
<script language="java script">
<!--
function goToURL() { //v2.0
for (var i=0; i< (goToURL.arguments.length - 1); i+=2) //with arg pairs
eval(goToURL.arguments+".location='"+goToURL.arguments[i+1]+"'");
document.returnvalue = false;
}
//-->
</script>
<body bgcolor="#FFFFFF" onLoad="goToURL('parent','將這裡改成要轉入的網址');return document.returnvalue">
</body>
</html>
-
------------------------------------------------------------------------------

不隱藏轉向之後的地址 代碼三
------------------------------------------------------------------------------- 
<html>
<head>
<meta http-equiv="Content-Language" content="zh-CN">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title></title>
</head>
<SCRIPT LANGUAGE="java script">
<!-- Start Code
var ver = navigator.appVersion;
if (ver.indexOf("MSIE") != -1)
{
window.location.href="將這裡改成要轉入的網址"
}else
window.location.href="將這裡改成要轉入的網址"
// End Code -->
</SCRIPT>
</html>
-------------------------------------------------------------------------------

不隱藏轉向之後的地址 代碼四
------------------------------------------------------------------------------- 
<html>
<head>
<meta http-equiv="Content-Language" content="zh-CN">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title></title>
</head>
<body>
<meta http-equiv="refresh" content="0.1;url=將這裡改成要轉入的網址">
</body>
</html>
-------------------------------------------------------------------------------

可隱藏轉向之後的地址
-------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Language" content="zh-CN">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title></title>
</head>
<frameset framespacing="0" border="0" rows="0" frameborder="0">
<frame name="main" src="將這裡改成要轉入的網址" scrolling="auto" noresize>
</frameset>
</html>
透明Flash的設定
++++++++++++++++++++++++++++++++++++++++++++++++++
主要是在Flash程式碼片段中插入這一語句:<param name=wmode value=transparent>,請看以下執行個體:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%">
<param name="movie" value="../images/hudie.swf">
<param name="quality" value="high">
<param name=wmode value=transparent> <!--這個代碼錶示背景透明--!>
<embed src="../images/hudie.swf" width="100%" height="100%" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
</object>

html中跳轉最全代碼
程式碼
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>正在進入</title>
</head>
<body>
<form name=loading> 
 <p align=center> <font color="#0066ff" size="2">正在進入,請稍等</font><font color="#0066ff" size="2" face="Arial">...</font>
  <input type=text name=chart size=46 > 
  
  <input type=text name=percent size=47 > 
  <script>  
var bar=0  
var line="||"  
var amount="||"  
count()  
function count(){  
bar=bar+2  
amount =amount + line  
document.loading.chart.value=amount  
document.loading.percent.value=bar+"%"  
if (bar<99)  
{setTimeout("count()",100);}  
else  
{window.location = "http://www.txasp.com/";}  
}</script> 
 </p> 
</form> 
<p align="center"> 如果您的瀏覽器不支援跳轉,<a href="http://www.txasp.com/"><font color="#FF0000">請點這裡</font></a>.</p>
</body>
</html>

html的meta方式
這種方法的好處是可以控制重新導向的時間
程式碼<meta http-equiv='Refresh' content='0;URL=index.html'>

在 <body> 裡添加代碼程式碼
<body onload="location.href='http://www.txasp.com/'">

HTTP Header referer這玩意主要是告訴人們我是從哪兒來的,就是告訴人家我是從哪個頁面過來的,可以用於統計訪問本網站的使用者來源,也可以用來防盜鏈。擷取這個東西最好的方式是js,如果在伺服器端擷取(方法如:Request.Headers["Referer"]) 不靠譜,人家可以偽造,用js擷取最好,人家很難偽造,方法:利用js的 document.referer 方法可以準確地判斷網頁的真實來路。 目前百度統計,google ads統計,CNZZ統計,都是用的這個方法。防盜鏈也很簡單了,js裡判斷來路url如果不是本站不顯示圖片

 

 

 

 

 

在IE中用javascript做跳轉,比如用window.location.href = “http://www.google.com”; google無法取到瀏覽器請求的HTTP referrer,因為IE清空了document.referrer

而其他主流瀏覽器Firefox和Chrome都會保留referrer,這意味著IE又要享受“部長級”特殊待遇了:

view source
1 if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
2     var referLink = document.createElement('a');
3     referLink.href = url;
4     document.body.appendChild(referLink);
5     referLink.click();
6 else {
7     location.href = url;
8

}

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.