자바 중급 (JAVA-Web) 강좌 자료] 쿠키
자바 중급 (JAVA-Web) 강좌 자료] 쿠키
실무개발자를위한 실무교육 전문교육센터학원
www.oraclejava.co.kr에 오시면 보다 다양한 강좌를 보실 수 있습니다.
쿠키
•서블릿 또는 JSP에서 생성
•저장위치는 클라이언트 메모리 또는 HD
•문자열만 저장 가능
•저장형태는 이름과 값으로 저장
•웹서버로 재접속할때 요청 HTTP 헤더에 포함
•쿠키 생성 방법
String strName = “name”;
String strValue = URLEncoder.encode(“홍길동”, "euc-kr");
Cookie cookie = new Cookie(strName, stryValue);
cookie.setMaxAge(intSecond);
cookie.setPath(strURI);
cookie.setDomain(strDomain);
•쿠키값 얻기
Cookie[] cookies = request.getCookies();
Cookie cookie = null;
if(cookies != null) {
for(int i=0; i<cookies.length; i++) {
String cookieName = cookies[i].getName();
if(cookieName.equals(“name")) {
cookie = cookies[i];
}
}
}
if(cookie!=null) {
String strValue = URLDecoder.decode(cookie.getValue(), "euc-kr");
}
'자바' 카테고리의 다른 글
자바 중급 (JAVA-Web) 강좌 자료] application 객체 이용 (0) | 2017.08.06 |
---|---|
자바 중급 (JAVA-Web) 강좌 자료] session 객체 이용 (0) | 2017.08.06 |
자바 중급 (JAVA-Web) 강좌 자료] 숨김 필드 (0) | 2017.08.06 |
자바 중급 (JAVA-Web) 강좌 자료] 접속간 정보 유지 기법 (0) | 2017.08.06 |
자바 중급 (JAVA-Web) 강좌 자료] 예외처리 (0) | 2017.08.06 |