ÄíÅ°¿¡ ´ëÇÏ¿©


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :ÇÏÁ¤¿ì 2000³â 3¿ù 29ÀÏ 18:36:11

In Reply to: cookie¿¡ ´ëÇؼ­ µµ¿ÍÁֽǺРposted by ¼ºÃ¢ÈÆ on 2000³â 3¿ù 29ÀÏ 12:05:46:

Cookie´Â Name/Value ½ÖÀÔ´Ï´Ù.
Servlet¿¡¼­´Â ÀÌ·¯ÇÑ CookieÀÇ ¹è¿­µéÀÌ HttpServletRequest¿¡¼­ Àü´ÞÀÌ µÇÁÒ.
Servlet¿¡¼­
HttpServletRequest.getCookies()¿¡¼­ ÇöÀç ÄíÅ° Á¤º¸¸¦ ÀÐ¾î ¿Ã ¼ö ÀÖ°í,
HttpServletResponse.addCookies(Cookie)¸¦ ÀÌ¿ëÇÏ¿© ÄíÅ°¸¦ »õ·Ó°Ô ¼³Á¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.


ÄíÅ° Á¤º¸¸¦ ÇÑ ¹ø ¼ÂÆà ÇØ ³õÀ¸¸é ºê¶ó¿ìÀú¸¦ Á¾·áÇϰųª ÀÏÁ¤½Ã°£ (ÀÌ°Ç ¼³Á¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.)ÀÌ Áö³ª¸é Áö¿öÁý´Ï´Ù. ºê¶ó¿ìÀú¿¡¼­ JavascriptµîÀ¸·Î »õ·Î¿î âÀ» ¿­ ¶§µµ ÄíÅ° Á¤º¸´Â °¡Áö°í °©´Ï´Ù.


¸¸¾à Login°°Àº °ÍÀ» ServletÀ¸·Î ±¸ÇöÇÒ °æ¿ì
óÀ½¿¡ LoginÇÒ ¶§, addCookie()¸¦ ÇϽŠÈÄ
´ÙÀ½ ÆäÀÌÁöµé¿¡´Â getCookie()¸¦ Çؼ­ ¿Ã¹Ù¸¥ »ç¿ëÀÚÀÎÁö¸¦ üũÇÏ¸é µË´Ï´Ù.


EX 1> Cookie¸¦ »ý¼ºÇÏ´Â °æ¿ì.
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Cookie user = new Cookie("user", req.getParameter("user"));
Cookie passwd = new Cookie("passwd", req.getParameter("passwd"));


res.addCookie(user);
res.addCookie(passwd);


// DO SOMETHING
}
-------------------------------------------------
EX 2> ÄíÅ° Á¤º¸¸¦ ÀÐ¾î ¿À´Â °æ¿ì.
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Cookie [] cook = req.getCookies();
String name = null;
String passwd = null;
int i = 0;
while (cook[i] != null) {
if (cook[i].getName().equals("name")) {
name = cook[i].getValue();
}
if (cook[i].getName().equals("passwd")) {
passwd = cook[i].getValue();
}
i++;
}
}


// DO SOMETHING
}
-------------------------------------------------
´ÙÀ½ »çÀÌÆ®¿¡ °¡¸é API¿¡ ´ëÇÑ ³»¿ëÀ» º¸½Ç ¼ö ÀÖ½À´Ï´Ù.
http://java.sun.com/products/servlet/2.2/javadoc/index.html


´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]