현재 쿠키1
<%@ page contentType="text/html; charset=euc-kr" %>
<HTML>
<HEAD>
<TITLE>setDomain() 메서드 사용하기</TITLE>
</HEAD>
<BODY>
<%
Cookie cookie1 = new Cookie("name", "Jimmy");
response.addCookie(cookie1);
Cookie cookie2 = new Cookie("phone", "010-1111-2222");
cookie2.setDomain("java.sun.com");
response.addCookie(cookie2);
%>
<H2>현재 쿠키</H2>
<%=cookie1.getName()%> : <%=cookie1.getValue()%><br>
<%=cookie2.getName()%> : <%=cookie2.getValue()%><br>
<A HREF="8-2.jsp">쿠키 확인하기</A>
</BODY>
</HTML>
현재 쿠키2
<%@ page contentType="text/html; charset=EUC-KR" buffer="none" %>
<html>
<head>
<title>setPath() 메서드 사용하기</title>
</head>
<body>
<%
Cookie cookie1 = new Cookie("name", "Jimmy");
response.addCookie(cookie1);
Cookie cookie2 = new Cookie("phone", "010-1111-2222");
cookie2.setPath("/JSP");
response.addCookie(cookie2);
Cookie cookie3 = new Cookie("address", "Seoul");
cookie3.setPath("/JSP/path2");
response.addCookie(cookie3);
%>
<H2>현재 쿠키</H2>
<%= cookie1.getName() %> : <%= cookie1.getValue() %>
(path : <%= cookie1.getPath() %>)<BR>
<%= cookie2.getName() %> : <%= cookie2.getValue() %>
(path : <%= cookie2.getPath() %>)<BR>
<%= cookie3.getName() %> : <%= cookie3.getValue() %>
(path : <%= cookie3.getPath() %>)<BR>
<a href="/JSP/8-2.jsp">/에서 쿠키 확인하기</a><br>
<a href="/JSP/path1/8-2.jsp">/path1에서 쿠키 확인하기</a><br>
<a href="/JSP/path2/8-2.jsp">/path2에서 쿠키 확인하기</a><br>
<a href="/JSP/path3/8-2.jsp">/path3에서 쿠키 확인하기</a>
</body>
</html>
세상을 링크하라!!! 모든 링크를 한 자리에...
링크닷컴: https://linkdotcom.mycafe24.com/
유용한 링크, 링크닷컴 #무료 #링크사이트 #링크사이트
컴퓨터 및 일반 유용한 링크들을 모아 놓았습니다. 지금 바로 확인하세요!
linkdotcom.mycafe24.com