gpt4 book ai didi

java - 为什么我的 Servlet 创建一个 JSESSIONID cookie?

转载 作者:搜寻专家 更新时间:2023-11-01 02:26:31 27 4
gpt4 key购买 nike

<分区>

我正在使用 Servlet 开发一些东西。我正在这个程序中创建 cookie,并且正在创建一个名为 JSESSIONID 的 cookie,但是当我注释掉所有代码时,即使创建了 cookie。这是我的代码:

CookieDemoServlet.java:

public class CookieDemoServlet extends HttpServlet {

public void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {

/*String em = req.getParameter("email");
Cookie ck[] = req.getCookies();
if (ck != null) {
if (ck.length != 0) {
for (Cookie c : ck) {
String cn = c.getName();

if (cn.equals("JSESSIONID")) {

System.out.println("You are the Old User");
String cv = c.getValue();
String d = c.getDomain();

System.out.println(cn + "\t:" + cv + "\t:" + d);
}

} else {
System.out.println("Sorry,No Cookies Found");
}
}

HttpSession session = req.getSession();
boolean b = session.isNew();
if (b) {
System.out.println("You are the New user");
} else {
System.out.println("You are the Old User");
}

Cookie c1 = new Cookie("Email", em);
res.addCookie(c1);
Cookie c2 = new Cookie("Phone", "99999");
res.addCookie(c2);*/

RequestDispatcher rd = req.getRequestDispatcher("cookiedemo.jsp");
rd.forward(req, res);

}

}
}

可能是什么原因?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com