题记:一个cookie,整个下午都没有找到解决的办法。
一、遇到的问题
1. 情景:访问http://list.mall.daily.taobao.net/50024400/xxx,当前页面通过ajax请求广告,请求的域为http://tmatch.simba.taobao.com/xxx;广告引擎向页面种seesion范围的cookie名_back,用于标识翻页;
2. 问题:
点击当前页面的翻页,IE下广告不翻页?通过firebug与httpwatch对比,发现IE下cookie“_back”不正确。开始猜测是引擎种cookie的逻辑存在问题,但很多地方都在使用此接口,均没有问题。
且有人的机器翻页正常,此时怀疑是浏览器设置问题?再用httpwatch观察“http请求头”,发现_back没有回传给引擎(其实httpwatch的cookies也可以观察到,如果发送cookie的话,会显示为Sent;之前只观察到Received)? 确认是浏览器的问题。
3. 解决:打开IE隐私设计,通常默认设置为“中”,拒绝“没有隐私政策的第三方cookie ...”,意味着_back并没有成功写入客户端,所有请求引擎导致不能正确回传_back,翻页失败。
这么说淘宝所有的广告的翻页都是不可用的 ?肯定不是。问题在”第一方 Cookie 来自您正浏览的网站,它们可以是永久的或临时的;第三方 Cookie 来自您正浏览的网站上的其他网站的广告”,对于浏览器“taobao.net与taobao.com”就是不同的两个网站,所以引擎的_back是无法种在客户端。此情景是daliy环境,线上的环境访问的是list.mall.daily.taobao.com,所以不存在“第三方cookie”的概念,广告是可以正确显示。
二、关于cookie小知识
1.IE Cookie的格式
第一行“名称”,第二行“值”,第三行“所属域” ...比如“.taobao.com”存在cna,此cookie会被浏览器自动发送到任何属于此域的子域;www.taobao.com\taobao.com,后面的是根域,前一个是二级域。xp存放目录为:C:\Documents and Settings\<username>\Cookies\,文件命名:你的用户名@生成COOKIE的domain[COOKIE改变的次数].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的关系
根本的原因:http协议的无状态性,cookie的出现就是为了解决这个问题。
session是一种在客户端与服务器之间保持状态的解决方案。服务端存储内容,返回对应的key给客户端,当下次访问时,带上此key,实现状态的维持。
session实现:
1.依赖cookie,The session cookie is stored in temporary memory and is not retained after the browser is closed。(实际测试:IE8,未在1描述的位置找到session级别cookie对应的文件,猜测‘临时存储在浏览器内存’,当关闭浏览器时则丢失key)
2.url重写。Servlet规范定义此功能。当浏览器禁用cookie时,就算session级别的内容也不会被存储。resp.encodeRedirectURL(url),且仅当禁用cookie时有效,重写结果如:http://www.demo.com/cookie.do;jsessionid=19gfy1sg740dl1whwd72lbqlhb
疑问:server如何判断,是否需要重写呢?从实验现象看,判断是否收到name=JSESSIONID 的cookie,若无,则进行url重写。
最好的方式,翻翻tomcat、jetty的源码实现,但未找到对应的代码。
关于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”生成中间表,再根据where条件筛选结果;但此方法非常低效,SQL具体的实现可能是 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.
请参见官网:
http://androidappdocs.appspot.com/sdk/installing.html
1. preparing your development computer
检查系统环境是否满足要求(基本忽略)
2.下载sdk
path 增加 %android_home%/tools
3. eclipse开发环境
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驱动只有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手机上,进行程序的调试、运行等。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,即可看到源码。
今天发现,之前的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、选择对应版本api、usb driver(请务必记住:选择使用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字节码文件是如何被找到的?内容:全部借鉴《Java深度历险》
Package:命名空间的问题,隔离类之间的关系。
Import:声明引入的类的路径(仅在编译时有作用,编译后的文件,类的声明已经为全路径);好处“明晰的代码结构,分离在多个文件;帮助实现动态链接的功能”。
一、编译
package
edu.nctu;
import
com.taobao.Test;
import
edu.nctu.*;
public
class C
{
public void print() {
System.out.println("package
test") ;
}
}
步骤:
1. 根据classpath建立,“类相对路径参考表”
如:javac –cp .;d:/test/,在d:/下执行,结果:d:/;d:/test/。
2. 以“类相对路径参考表”作为相对起始路径,验证能够找到所有要用的package。
根据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.
如果已经存在A .class文件,A .java不是必须的;
2.
编译器在找到源码或字节码,对会验证是否属于此package,但没有通过make机制的编译,是不会验证的;make机制,即编译器自动维护具有相互依赖关系的文件;javac命令直接编译文件,如:javac -cp d:/test com.edu.C.java,编译器角度:com.edu.C.java 是一个文件名,且没有通过make机制,所以-cp指定的路径建立的“类相对路径参考表”也不会使用,编译器直接在当前目录下查找com.edu.C.java,结果 ClassNotFoundException 。
二、运行
1、 编译结束后,import指令已经不存在,类被替换为“全限定类名”
2、 运行时类的加载,都是通过classloader进行,所以必须遵循正确的“包目录”结构,不管是否直接通过命令行执行。
步骤:
1.
建立“字节码路径参考表”,根据classpath
2.
绝对路径 = “字节码路径参考表”+ 全限定类名,查找;加载;找不到,报错。
摘要: 已迁往 http://fatmind.iteye.com主要参考:
1.宝宝的文章《中文化和国际化问题浅析》
2.阮一峰的网络日志
http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html
 ...
阅读全文