cookieSetter.jsp
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.espeed.reading.util.ConfigPath"%>
<%@ page import="com.espeed.reading.util.ConstantUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>cookie setter</title>
</head>
<body>
<%
String domain = ConfigPath.getClickDomain();
String jsessionId = request.getParameter("jsessionId");
String identity = request.getParameter("identity");
String emails = request.getParameter("emails");
String uid = null;
String email = "";
if (domain == null || domain.trim().isEmpty()) {
domain = "yiwaixiao.com";
}
Cookie cookie = null;
if (jsessionId != null && !jsessionId.trim().isEmpty()) {
cookie = new Cookie("JSESSIONID", jsessionId);
response.addCookie(cookie);
}
if (identity != null && !identity.trim().isEmpty()) {
cookie = new Cookie(ConstantUtil.USER_IDENTITY_COOKIE, identity);
cookie.setMaxAge(ConstantUtil.HALF_CENTURY);
cookie.setDomain(domain);
response.addCookie(cookie);
}
Cookie[] cookies = request.getCookies();
if (cookies != null && cookies.length > 0) {
for (Cookie c : cookies) {
if (ConstantUtil.USER_IDENTITY_COOKIE.equals(c
.getName())) {
uid = c.getValue();
}
if (c.getName().startsWith(
ConstantUtil.EMAIL_IDENTITY_COOKIE)) {
if (emails != null && !emails.trim().isEmpty()) {
if (!emails.contains(c.getValue())) {
email = "," + c.getValue();
}
} else {
email = "," + c.getValue();
}
}
}
}
if (!email.isEmpty()) {
if (emails != null && !emails.trim().isEmpty()) {
emails += email;
} else {
emails = email.substring(1);
}
}
if (emails != null && !emails.trim().isEmpty()) {
String[] emailArr = emails.split(",");
if (emailArr.length > 0) {
for (int i = 0; i < emailArr.length; i++) {
cookie = new Cookie(ConstantUtil.EMAIL_IDENTITY_COOKIE
+ "_" + i, emailArr[i]);
cookie.setMaxAge(ConstantUtil.HALF_CENTURY);
cookie.setDomain(domain);
response.addCookie(cookie);
}
}
}
%>
</body>
</html>