출처

JSP QnA
http://www.okjsp.pe.kr/seq/39964

급*넘
2003-12-18 01:37:44.0
 
쿠키에 한자랑 한글집어 넣을려고하는데요
제가 jsp초본데여.
URLEncode(xxx,"EUC-KR")이넘을 써봐도.....
US-ASCII를 써봐도.. 그냥 넣어봐도.....

안드가져여..ㅡ.,ㅡ;;;;
str = java.net.URLEncode("아아아","EUC-KR");
response.setHeader("set-cookie","key="+str);
이런.. 헤더에 직접 때려밖는 구문을 썼는데여.
그어떤넘을 써봐도 안드가집니다..

어케 해야지 한글이랑 한자랑 넣을수 있을까여???

어렵네!!
  • 학생
  • 2003-12-18 13:29:51
  • x
  • // 쿠키 생성하는 페이지에서
    String str = java.net.URLEncoder.encode("아아아", "MS949");
    Cookie cookie = new Cookie("key", str);
    response.addCookie(cookie);


    // 생성된 쿠키를 확인하는 페이지에서
    Cookie[] cookies = request.getCookies();
    if ((cookies != null) && (cookies.length > 0)) {
    for (int i = 0; i < cookies.length; i++) {
    Cookie c = cookies[i];
    out.println((i+1) + "번째 쿠키 정보<BR>");
    out.println("<UL>");
    out.println("<LI>쿠키 이름: " + c.getName() + "<BR>");
    out.println("<LI>URL 디코드된 쿠키 이름: " + java.net.URLDecoder.decode(c.getName()) + "<BR>");
    out.println(" <UL>");
    out.println(" <LI>쿠키 값: " + c.getValue() + "</LI>");
    out.println(" <LI>URL 디코드된 쿠키 값: " + java.net.URLDecoder.decode(c.getValue(), "MS949") + "</LI>");
    out.println(" </UL>");
    out.println("</UL>");
    out.println("<HR WIDTH=200 ALIGN=left>");
    }
    }
    else {
    out.println("쿠기 없음");
    }
  • javaclue
  • 2003-12-18 19:56:15
  • x