본문 바로가기

개인 공부방/JSP

쿠키 만들기


cookieMake.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<h2> Cookie - 생성 페이지</h2>


<%

Cookie cookie = new Cookie("id","aaa");

response.addCookie(cookie);

%>


확인 : <input type="button" value="확인"

onclick="javascript:window.location='cookieUse.jsp'">


 


cookieUse.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>


    

<h2> Cookie - 확인 페이지</h2>

<%

Cookie[] cookies = request.getCookies();

for(int i = 0; i <cookies.length; i++){

if(cookies[i].getName().equals("id")){

%>

이름 : <%=cookies[i].getName() %><br>

값 : <%=cookies[i].getValue() %>

<%

}

}


%>

 

파일 백업 111216
 

'개인 공부방 > JSP' 카테고리의 다른 글

member  (0) 2011.12.19
session 생성  (0) 2011.12.19
Connection Pool 2  (0) 2011.12.16
Connection Pool 1. 서버설정  (2) 2011.12.16
JDBC  (0) 2011.12.15