728x90
728x90
BIG
쿠키 객체 생성
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
//쿠키객체 생성
Cookie cookie = new Cookie("id","malja");
//쿠키 시간 설정 1초
cookie.setMaxAge(60*60);//1시간
//레스폰스에 쿠키를 담아서 보냄
response.addCookie(cookie);
//다른 페이지에서도 가능
response.sendRedirect("cookConfirm.jsp");
%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Cookie[] cookies = request.getCookies();
for(Cookie c : cookies){
out.print(c.getName()+" - "+c.getValue()+"<br>");
}
%>
</body>
</html>
728x90
반응형
BIG
'🎵JSP' 카테고리의 다른 글
[JSP] Bean에 담아 게시판 만들기 (0) | 2023.02.10 |
---|---|
[JSP]Session (0) | 2023.02.09 |
[JSP] Run On Server (Always use this server when running this project 해제하는 법) (0) | 2023.02.09 |
[JSP]pageContext(ServletRequest,getRequest,forward,include) (0) | 2023.02.09 |
[JSP]설문조사form - include (0) | 2023.02.09 |
댓글