JSPÖеÄCOOKIE²Ù×÷
JSPÖеÄCOOKIE²Ù×÷
Cookie¸ÅÄî:
CookieµÄ¸ñʽʵ¼ÊÉÏÊÇÒ»¶Î´¿Îı¾ÐÅÏ¢, ÓÉ·þÎñÆ÷Ëæ×ÅÍøÒ³Ò»Æð·¢Ë͵½¿Í»§¶Ë, ²¢±£´æÔÚ¿Í»§¶ËÓ²ÅÌÖÐÖ¸¶¨µÄĿ¼µÄ. ´ó¼Ò¶¼´«ËµCookie»áÔì³ÉÑÏÖصݲȫÍþвʲôµÄ, Æäʵ²»ÊÇÕâô»ØÊÂÇé. ·þÎñÆ÷¶ÁÈ¡CookieµÄʱºò, Ö»Äܹ»¶ÁÈ¡µ½Õâ¸ö·þÎñÆ÷Ïà¹ØµÄÐÅÏ¢. ¶øÇÒ, ä¯ÀÀÆ÷Ò»°ãÖ»ÔÊÐí´æ·Å300¸öCookie, ÿ¸öÕ¾µã×î¶à´æ·Å20¸ö, ¶øÇÒ, ÿ¸öCookieµÄ´óСÏÖÔÚÔÚ4K, ¸ù±¾²»»áÕ¼ÓöàÉÙ¿Õ¼ä. ²¢ÇÒ, CookieÊÇÓÐʱЧÐÔÖʵÄ. ÀýÈç, ÉèÖÃÁËCookieµÄ´æ»îʱ¼äΪ1·ÖÖÓ, ÔòÒ»·ÖÖÓºóÕâ¸öCookie¾Í»á±»ä¯ÀÀÆ÷ɾ³ý
Cookie°æ±¾:
Ä¿Ç°ÓÐÁ½¸ö°æ±¾:
°æ±¾0 : ÓÉNetscape¹«Ë¾Öƶ¨µÄ£¬Ò²±»¼¸ºõËùÓеÄä¯ÀÀÆ÷Ö§³Ö. JavaÖÐΪÁ˱£³Ö¼æÈÝÐÔ, Ä¿Ç°Ö»Ö§³Öµ½°æ±¾0, CookieµÄÄÚÈÝÖв»ÄÜ¿Õ¸ñ£¬·½À¨ºÅ£¬Ô²À¨ºÅ£¬µÈÓںţ¨=£©£¬¶ººÅ£¬Ë«ÒýºÅ£¬Ð±¸Ü£¬Îʺţ¬@·ûºÅ£¬Ã°ºÅ£¬·ÖºÅ¡£
°æ±¾1 : ¸ù¾ÝRFC 2109ÎĵµÖƶ¨µÄ. ·Å¿íÁ˺ܶàÏÞÖÆ. ÉÏÃæËùÏÞÖƵÄ×Ö·û¶¼¿ÉÒÔʹÓÃ. µ«ÎªÁ˱£³Ö¼æÈÝÐÔ, Ó¦¸Ã¾¡Á¿±ÜÃâʹÓÃÕâЩÌØÊâ×Ö·û.
JSPÖжÔCookieµÄ²Ù×÷: ÀàÐÍ ·½·¨Ãû ·½·¨½âÊÍ
String getComment() ·µ»ØcookieÖÐ×¢ÊÍ,Èç¹ûûÓÐ×¢Ê͵Ļ°½«·µ»Ø¿ÕÖµ.
String getDomain() ·µ»ØcookieÖÐCookieÊÊÓõÄÓòÃû. ʹÓÃgetDomain() ·½·¨¿ÉÒÔָʾä¯ÀÀÆ÷°ÑCookie·µ»Ø¸øͬ Ò»ÓòÄÚµÄÆäËû·þÎñÆ÷,¶øͨ³£CookieÖ»·µ»Ø¸øÓë·¢ËÍËüµÄ·þÎñÆ÷Ãû×ÖÍêÈ«ÏàͬµÄ·þÎñÆ÷¡£×¢ÒâÓòÃû±ØÐëÒԵ㿪ʼ
int getMaxAge() ·µ»ØCookie¹ýÆÚ֮ǰµÄ×î´óʱ¼ä£¬ÒÔÃë¼ÆËã¡£
String getName() ·µ»ØCookieµÄÃû×Ö
String getPath() ·µ»ØCookieÊÊÓõÄ·¾¶¡£Èç¹û²»Ö¸¶¨Â·¾¶£¬Cookie½«·µ»Ø¸øµ±Ç°Ò³ÃæËùÔÚĿ¼¼°Æä×ÓĿ¼Ï µÄËùÓÐÒ³Ãæ¡£
boolean getSecure() Èç¹ûä¯ÀÀÆ÷ͨ¹ý°²È«ÐÒé·¢ËÍcookies½«·µ»ØtrueÖµ£¬Èç¹ûä¯ÀÀÆ÷ʹÓñê×¼ÐÒéÔò·µ»ØfalseÖµ¡£
String getValue() ·µ»ØCookieµÄÖµ¡£±ÊÕßÒ²½«ÔÚºóÃæÏêϸ½éÉÜgetValue/setValue¡£
int getVersion() ·µ»ØCookieËù×ñ´ÓµÄÐÒé°æ±¾¡£
void setComm
Ïà¹ØÎĵµ£º
²»´¦ÀíÌåÄÚÈݵıêÇ©Àí½âÒ»ÏÂͼƬ1
´¦ÀíÌåÄÚÈݱêÇ©Àí½âÌáͼƬ2
1£ºJspWriter out = pageContext.getOut();
2£ºBodyContent bc = this.getBodyContent();
3£ºString input = bc.getString();
4£ºJspWriter out = bc.getEnclosingWriter();
²»´¦ÀíÌåÄÚÈÝ
µÚÒ»ÐдúÂëΪ²»´¦Àí±êÇ©ÌåÄÚÈÝʱÄõ½ÐèÒªµÄÊä³öµ½Ò³ ......
jspʹÓÃ×é¼þ½øÐÐÎļþÉÏ´«
WEBÎļþÉÏ´«¿ÉÄÜÊÇÍøÕ¾½¨ÉèÖÐ×î³£ÓõŦÄÜÖ®Ò»£¬ÎÒÔÚÏîÄ¿¿ª·¢Öм¸ºõ¶¼ÐèҪʵÏÖÎļþÉÏ´«¹¦ÄÜ£®Ç°¶Îʱ¼ä×Ô¼ºËѼ¯ÁËһЩÉÏ´«×é¼þ£®ÕâƪÎÄÕÂÖн«½éÉÜÕâЩ×é¼þµÄʹÓ÷½·¨£¬²¢ÇұȽϸ÷×ÔµÄÓÅÁÓ£®
Ò»£¬smartupload×é¼þ£®
ÎÒÏëÖ»Òª×ö¸öÎļþÉÏ´«µÄÅóÓѶ¼ÖªµÀÕâ¸ö×é¼þ£¬ÎÒÈÏʶµÄÈËÖÐʹÓÃ×î¶àµÄÒ²ÊÇËü£¡ÎÒ¸ ......
1.±ØÐë¼Ì³Ð×ÔHttpServlet
2.±ØÐëʵÏÖdoGet()»òÕßdoPost()
3.±ØÐëÔÚweb.xmlÖÐÅäÖÃServlet
<servlet>
<servlet-name> </servlet-name>
<servlet-class> </servlet-class>
</servlet>
<servlet-mapping>
......
×Ô¶¨Òå±êÇ©ÊÇÈÿª·¢ÈËÔ±´´½¨¿Í»§»¯µÄ±êÇ©,²¢ÇÒÔÚjspÎļþÖÐʹÓÃÕâЩ±êÇ©,ÕâÑù¿ÉÒÔʹjsp´úÂë¸ü¼ò½à!
Ê×ÏÈÕâÀïÏȽéÉÜ´Ó¶¨Òå±êÇ©µ½Ê¹ÓñêÇ©µÄ²½Öè:
1,´´½¨×Ô¶¨Òå±êÇ©´¦ÀíÀà,¼°Ïà¹ØÀà.class ²¢ÇÒ°ÑËûÃǶ¼·ÅÔÚWEB-INF/classesĿ¼ÏÂ
2,´´½¨TLD±êÇ©¿âÃèÊöÎļþ(.tld)Î ......