can the following experiment summarize the principle in a few short sentences? At present, all I know is that the facts are as follows
.:Tomcat
:localhost:8080/project
Servlet:localhost:8080/project/MyCookie
localhost:8080/project/MyCookieServlet:
public class MyCookie extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
Cookie[] cookies = request.getCookies();
for(int i = 0; cookies != null && i < cookies.length;iPP){
//,cookie
response.getWriter().println("cookie cookies[i].getName():"+cookies[i].getName()+cookies[i].getValue());
}
}
}
:
1.,TomcatCookie,
:
Set-Cookie:JSESSIONID=544F9C73731E416ECC15CF5A204C2023; Path=/project; HttpOnly;
2.,Tomcat
Cookie,,cookie,:
Cookie:JSESSIONID=544F9C73731E416ECC15CF5A204C2023
3Cookie;
4.Servletlocalhost:8080/project/MyCookie ,
,Servlet,Cookie
5),(4)Servlet,
Servletcookie