題記:一個cookie,整個下午都沒有找到解決的辦法。
一、遇到的問題
1. 情景:訪問http://list.mall.daily.taobao.net/50024400/xxx,當前頁面通過ajax請求廣告,請求的域為http://tmatch.simba.taobao.com/xxx;廣告引擎向頁面種seesion范圍的cookie名_back,用于標識翻頁;
2. 問題:
點擊當前頁面的翻頁,IE下廣告不翻頁?通過firebug與httpwatch對比,發(fā)現(xiàn)IE下cookie“_back”不正確。開始猜測是引擎種cookie的邏輯存在問題,但很多地方都在使用此接口,均沒有問題。
且有人的機器翻頁正常,此時懷疑是瀏覽器設(shè)置問題?再用httpwatch觀察“http請求頭”,發(fā)現(xiàn)_back沒有回傳給引擎(其實httpwatch的cookies也可以觀察到,如果發(fā)送cookie的話,會顯示為Sent;之前只觀察到Received)? 確認是瀏覽器的問題。
3. 解決:打開IE隱私設(shè)計,通常默認設(shè)置為“中”,拒絕“沒有隱私政策的第三方cookie ...”,意味著_back并沒有成功寫入客戶端,所有請求引擎導(dǎo)致不能正確回傳_back,翻頁失敗。
這么說淘寶所有的廣告的翻頁都是不可用的 ?肯定不是。問題在”第一方 Cookie 來自您正瀏覽的網(wǎng)站,它們可以是永久的或臨時的;第三方 Cookie 來自您正瀏覽的網(wǎng)站上的其他網(wǎng)站的廣告”,對于瀏覽器“taobao.net與taobao.com”就是不同的兩個網(wǎng)站,所以引擎的_back是無法種在客戶端。此情景是daliy環(huán)境,線上的環(huán)境訪問的是list.mall.daily.taobao.com,所以不存在“第三方cookie”的概念,廣告是可以正確顯示。
二、關(guān)于cookie小知識
1.IE Cookie的格式
第一行“名稱”,第二行“值”,第三行“所屬域” ...比如“.taobao.com”存在cna,此cookie會被瀏覽器自動發(fā)送到任何屬于此域的子域;www.taobao.com\taobao.com,后面的是根域,前一個是二級域。xp存放目錄為:C:\Documents and Settings\<username>\Cookies\,文件命名:你的用戶名@生成COOKIE的domain[COOKIE改變的次數(shù)].txt
參考:http://blog.csdn.net/zhangxinrun/archive/2010/07/31/5779574.aspx
2.Js Cookie跨域訪
http://blog.csdn.net/tongdoudpj/archive/2009/05/10/4166096.aspx
3.cookie與session的關(guān)系
根本的原因:http協(xié)議的無狀態(tài)性,cookie的出現(xiàn)就是為了解決這個問題。
session是一種在客戶端與服務(wù)器之間保持狀態(tài)的解決方案。服務(wù)端存儲內(nèi)容,返回對應(yīng)的key給客戶端,當下次訪問時,帶上此key,實現(xiàn)狀態(tài)的維持。
session實現(xiàn):
1.依賴cookie,The session cookie is stored in temporary memory and is not retained after the browser is closed。(實際測試:IE8,未在1描述的位置找到session級別cookie對應(yīng)的文件,猜測‘臨時存儲在瀏覽器內(nèi)存’,當關(guān)閉瀏覽器時則丟失key)
2.url重寫。Servlet規(guī)范定義此功能。當瀏覽器禁用cookie時,就算session級別的內(nèi)容也不會被存儲。resp.encodeRedirectURL(url),且僅當禁用cookie時有效,重寫結(jié)果如:http://www.demo.com/cookie.do;jsessionid=19gfy1sg740dl1whwd72lbqlhb
疑問:server如何判斷,是否需要重寫呢?從實驗現(xiàn)象看,判斷是否收到name=JSESSIONID 的cookie,若無,則進行url重寫。
最好的方式,翻翻tomcat、jetty的源碼實現(xiàn),但未找到對應(yīng)的代碼。
關(guān)于cookie的詳細信息參見: http://en.wikipedia.org/wiki/HTTP_cookie
請參考:http://en.wikipedia.org/wiki/Join_(SQL)#Sample_tables
inner JOINS
An inner join is the most common join operation used in applications and can be regarded as the default join-type. Inner join creates a new result table by combining column values of two tables (A and B) based upon the join-predicate. The query compares each row of A with each row of B to find all pairs of rows which satisfy the join-predicate. When the join-predicate is satisfied, column values for each matched pair of rows of A and B are combined into a result row. The result of the join can be defined as the outcome of first taking the Cartesian product (or cross-join) of all records in the tables (combining every record in table A with every record in table B)—then return all records which satisfy the join predicate. Actual SQL implementations normally use other approaches like a Hash join or a Sort-merge join where possible, since computing the Cartesian product is very inefficient.
注意:innner查詢(默認的連接查詢方式),是先查詢“Cartesian”生成中間表,再根據(jù)where條件篩選結(jié)果;但此方法非常低效,SQL具體的實現(xiàn)可能是 Hash join or a Sort-merge join 。
One can further classify inner joins as equi-joins, as natural joins, or as cross-joins.
SELECT *
FROM employee INNER JOIN department
ON employee.DepartmentID = department.DepartmentID;
The following example shows a query which is equivalent to the one from the previous example.
SELECT *
FROM employee, department
WHERE employee.DepartmentID = department.DepartmentID;
Outer joins
An outer join does not require each record in the two joined tables to have a matching record. The joined table retains each record—even if no other matching record exists. Outer joins subdivide further into left outer joins, right outer joins, and full outer joins, depending on which table(s) one retains the rows from (left, right, or both).
Example of a left outer join, with the additional result row italicized:
SELECT *
FROM employee LEFT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID;
Employee.LastName | Employee.DepartmentID | Department.DepartmentName | Department.DepartmentID |
Jones |
33 |
Engineering |
33 |
Rafferty |
31 |
Sales |
31 |
Robinson |
34 |
Clerical |
34 |
Smith |
34 |
Clerical |
34 |
John |
NULL |
NULL |
NULL |
Steinberg |
33 |
Engineering |
33
|
Example right outer join, with the additional result row italicized:
SELECT *
FROM employee RIGHT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID;
Employee.LastName | Employee.DepartmentID | Department.DepartmentName | Department.DepartmentID |
Smith |
34 |
Clerical |
34 |
Jones |
33 |
Engineering |
33 |
Robinson |
34 |
Clerical |
34 |
Steinberg |
33 |
Engineering |
33 |
Rafferty |
31 |
Sales |
31 |
NULL |
NULL |
Marketing |
35
|
Example full outer join: (mysql is not support)
SELECT *
FROM employee
FULL OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID;
Employee.LastName | Employee.DepartmentID | Department.DepartmentName | Department.DepartmentID |
Smith |
34 |
Clerical |
34 |
Jones |
33 |
Engineering |
33 |
Robinson |
34 |
Clerical |
34 |
John |
NULL |
NULL |
NULL |
Steinberg |
33 |
Engineering |
33 |
Rafferty |
31 |
Sales |
31 |
NULL |
NULL |
Marketing |
35
|
Self-join
A query to find all pairings of two employees in the same country is desired.
An example solution query could be as follows:
SELECT F.EmployeeID, F.LastName, S.EmployeeID, S.LastName, F.Country
FROM Employee F, Employee S
WHERE F.Country = S.Country
AND F.EmployeeID < S.EmployeeID
ORDER BY F.EmployeeID, S.EmployeeID;
Which results in the following table being generated.
Employee Table after Self-join by Country
EmployeeID | LastName | EmployeeID | LastName | Country |
123 |
Rafferty |
124 |
Jones |
Australia |
123 |
Rafferty |
145 |
Steinberg |
Australia |
124 |
Jones |
145 |
Steinberg |
Australia |
305 |
Smith |
306 |
John |
Germany
|
Join algorithms
Three fundamental algorithms exist for performing a join operation: Nested loop join, Sort-merge join and Hash join.
請參見官網(wǎng):
http://androidappdocs.appspot.com/sdk/installing.html
1. preparing your development computer
檢查系統(tǒng)環(huán)境是否滿足要求(基本忽略)
2.下載sdk
path 增加 %android_home%/tools
3. eclipse開發(fā)環(huán)境
eclipse3.5在線安裝地址 :
https://dl-ssl.google.com/android/eclipse/
4. 安裝 android平臺和其它組件
之前下載的包,僅是一個工具包。
The starter package is not a full development environment — it includes only the core SDK Tools, which you can use to download the rest of the SDK components.
我的選擇 :android platform、document、samples、google api、martket lience(請注意選擇的版本要一致)
Android USB驅(qū)動只有Windows才需要安裝,作用:Contains driver files that you can install on your Windows computer, so that you can run and debug your applications on an actual device. 可以直接在你的android手機上,進行程序的調(diào)試、運行等。linux、mac是不需要安裝。
5. hello world
http://developer.android.com/training/basics/firstapp/index.html
6. eclipse查看android源碼
http://log4think.com/browsing-android-source-in-eclipse/ 已驗證:<sdk-home>/platforms/android-8,建立source文件夾,將源碼放入。重啟eclipse,即可看到源碼。
今天發(fā)現(xiàn),之前的url也不能訪問;安裝方式也不同,重新整理。
1. 安裝sdk
http://developer.android.com/sdk/installing/index.html 下載sdk(windows下竟然是exe)
It includes only the core SDK tools, which you can use to download the rest of the SDK packages, using the Android SDK Manager. To develop an Android app, you also need to download at least one Android platform and the latest SDK Platform-tools。 選擇其它組件:tools、選擇對應(yīng)版本api、usb driver(請務(wù)必記住:選擇使用http,而不是https,tools->options)
2.安裝eclipse adt plugin
http://developer.android.com/sdk/installing/installing-adt.html select the checkbox next to Developer Tools and click Next.
config the adt plugin.
已遷往 http://fatmind.iteye.com
題記:.java源文件是如何被找到的?.class字節(jié)碼文件是如何被找到的?內(nèi)容:全部借鑒《Java深度歷險》
Package:命名空間的問題,隔離類之間的關(guān)系。
Import:聲明引入的類的路徑(僅在編譯時有作用,編譯后的文件,類的聲明已經(jīng)為全路徑);好處“明晰的代碼結(jié)構(gòu),分離在多個文件;幫助實現(xiàn)動態(tài)鏈接的功能”。
一、編譯
package
edu.nctu;
import
com.taobao.Test;
import
edu.nctu.*;
public
class C
{
public void print() {
System.out.println("package
test") ;
}
}
步驟:
1. 根據(jù)classpath建立,“類相對路徑參考表”
如:javac –cp .;d:/test/,在d:/下執(zhí)行,結(jié)果:d:/;d:/test/。
2. 以“類相對路徑參考表”作為相對起始路徑,驗證能夠找到所有要用的package。
根據(jù)import引入的package或全限定類名,import packagename.classname,將packagename之中的“.”以“/”取代.
2.1
若com.taobao.*形式,驗證在d:/目錄下是否存在com/taobao/目錄,若不存在,依次檢查d:/test/。
2.2
若com.taobao.Test形式,驗證是否存在com/taobao/Test,與上相同。
3. 建立“類參考表”和“相對類參考表”
3.1
類參考表:com.taobao.Test
3.2
類相對參考表:com.taobao.*
4. 解析class{} 包含的代碼
是否全限定類名
4.1
是,絕對路徑 =“類相對路徑參考表”+全限定類名,查找,不存在為錯誤;
4.2
否,絕對路徑 =“類相對路徑參考表”,查找;
4.2.1是,編譯
4.2.2否,解析package
4.2.2.1 在類參考表,是否存在1以上的同名類,出錯;否則,絕對路徑 =“類相對路徑參考表”+ “類參考表”,正確。
4.2.2.2 在類參考表找不到,絕對路徑
= “類相對路徑參考表”+ “相對類參考表”,若存在一個以上的類,出錯;否則,正確。
提醒:
1.
如果已經(jīng)存在A .class文件,A .java不是必須的;
2.
編譯器在找到源碼或字節(jié)碼,對會驗證是否屬于此package,但沒有通過make機制的編譯,是不會驗證的;make機制,即編譯器自動維護具有相互依賴關(guān)系的文件;javac命令直接編譯文件,如:javac -cp d:/test com.edu.C.java,編譯器角度:com.edu.C.java 是一個文件名,且沒有通過make機制,所以-cp指定的路徑建立的“類相對路徑參考表”也不會使用,編譯器直接在當前目錄下查找com.edu.C.java,結(jié)果 ClassNotFoundException 。
二、運行
1、 編譯結(jié)束后,import指令已經(jīng)不存在,類被替換為“全限定類名”
2、 運行時類的加載,都是通過classloader進行,所以必須遵循正確的“包目錄”結(jié)構(gòu),不管是否直接通過命令行執(zhí)行。
步驟:
1.
建立“字節(jié)碼路徑參考表”,根據(jù)classpath
2.
絕對路徑 = “字節(jié)碼路徑參考表”+ 全限定類名,查找;加載;找不到,報錯。
摘要: 已遷往 http://fatmind.iteye.com主要參考:
1.寶寶的文章《中文化和國際化問題淺析》
2.阮一峰的網(wǎng)絡(luò)日志
http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html
 ...
閱讀全文