JSP Ò³ÃæÖжÔCookieµÄ²Ù×÷
Ò».ʲôÊÇcookies£¿
¡¡¡¡´ó¼Ò¶¼ÖªµÀ£¬ä¯ÀÀÆ÷ÓëWEB·þÎñÆ÷Ö®¼äÊÇʹÓÃHTTPÐÒé½øÐÐͨÐŵģ¬µ±Ä³¸öÓû§·¢³öÒ³ÃæÇëÇóʱ£¬WEB·þÎñÆ÷Ö»ÊǼòµ¥µÄ½øÐÐÏìÓ¦£¬È»ºó¾Í¹Ø±ÕÓë¸ÃÓû§µÄÁ¬½Ó¡£Òò´Ëµ±Ò»¸öÇëÇó·¢Ë͵½WEB·þÎñÆ÷ʱ£¬ÎÞÂÛÆäÊÇ·ñÊǵÚÒ»´ÎÀ´·Ã£¬·þÎñÆ÷¶¼»á°ÑËüµ±×÷µÚÒ»´ÎÀ´¶Ô´ý£¬ÕâÑùµÄ²»ºÃÖ®´¦¿ÉÏë¶øÖª¡£ÎªÁËÃÖ²¹Õâ¸öȱÏÝ£¬Netscape¿ª·¢³öÁËcookieÕâ¸öÓÐЧµÄ¹¤¾ßÀ´±£´æij¸öÓû§µÄʶ±ðÐÅÏ¢£¬Òò´ËÈËÃÇêdzÆΪ“СÌð±ý”¡£cookiesÊÇÒ»ÖÖWEB·þÎñÆ÷ͨ¹ýä¯ÀÀÆ÷ÔÚ·ÃÎÊÕßµÄÓ²ÅÌÉÏ´æ´¢ÐÅÏ¢µÄÊֶΣºNetscape NavigatorʹÓÃÒ»¸öÃûΪcookies.txt±¾µØÎļþ±£´æ´ÓËùÓÐÕ¾µã½ÓÊÕµÄCookieÐÅÏ¢£»¶øIEä¯ÀÀÆ÷°ÑCookieÐÅÏ¢±£´æÔÚÀàËÆÓÚC:\\windows\\cookiesµÄĿ¼Ï¡£µ±Óû§ÔٴηÃÎÊij¸öÕ¾µãʱ£¬·þÎñ¶Ë½«ÒªÇóä¯ÀÀÆ÷²éÕÒ²¢·µ»ØÏÈÇ°·¢Ë͵ÄCookieÐÅÏ¢£¬À´Ê¶±ðÕâ¸öÓû§¡£
¡¡¡¡cookies¸øÍøÕ¾ºÍÓû§´øÀ´µÄºÃ´¦·Ç³£¶à£º
¡¡¡¡1¡¢CookieÄÜʹվµã¸ú×ÙÌض¨·ÃÎÊÕߵķÃÎÊ´ÎÊý¡¢×îºó·ÃÎÊʱ¼äºÍ·ÃÎÊÕß½øÈëÕ¾µãµÄ·¾¶
¡¡¡¡2¡¢CookieÄܸæËßÔÚÏß¹ã¸æÉ̹ã¸æ±»µã»÷µÄ´ÎÊý£¬´Ó¶ø¿ÉÒÔ¸ü¾«È·µÄͶ·Å¹ã¸æ
¡¡¡¡3¡¢CookieÓÐЧÆÚÏÞδµ½Ê±£¬CookieÄÜʹÓû§ÔÚ²»¼üÈëÃÜÂëºÍÓû§ÃûµÄÇé¿öϽøÈëÔø¾ä¯ÀÀ¹ýµÄһЩվµã
¡¡¡¡4¡¢CookieÄÜ°ïÖúÕ¾µãͳ¼ÆÓû§¸öÈË×ÊÁÏÒÔʵÏÖ¸÷ÖÖ¸÷ÑùµÄ¸öÐÔ»¯·þÎñ
¡¡¡¡ÔÚJSPÖÐ,ÎÒÃÇÒ²¿ÉÒÔʹÓÃCookie,À´±àдһЩ¹¦ÄÜÇ¿´óµÄÓ¦ÓóÌÐò¡£
¡¡¡¡ÏÂÃæ,ÎÒÏë½éÉÜÒ»ÏÂÈçºÎÓÃJSP´´½¨ºÍ´¦ÀíCookie¡£
¡¡¡¡¶þ£®ÈçºÎ´´½¨Cookie
¡¡¡¡¡¡import="javax.servlet.http.Cookie"
¡¡¡¡ËµÁËÕâô¶à£¬´ó¼ÒÒ»¶¨ºÜÏëÖªµÀJSPÊÇÈçºÎ´´½¨cookieÁË¡£JSPÊÇʹÓÃÈçϵÄÓï·¨¸ñʽÀ´´´½¨cookieµÄ£º
¡¡¡¡Cookie cookie_name =new Cookie("Parameter","Value");
¡¡¡¡ÀýÈ磺
Cookie username_Cookie =new Cookie("username","waynezheng");
response.addCookie(username_Cookie);
¡¡¡¡½âÊÍ£ºJSPÊǵ÷ÓÃCookie¶ÔÏóÏàÓ¦µÄ¹¹Ô캯ÊýCookie(name,value)ÓúÏÊʵÄÃû×ÖºÍÖµÀ´´´½¨Cookie£¬È»ºóCookie¿ÉÒÔͨ¹ýHttpServletResponseµÄaddCookie·½·¨¼ÓÈëµ½Set-CookieÓ¦´ðÍ·£¬
±¾ÀýÖÐCookie¶ÔÏóÓÐÁ½¸ö×Ö·û´®²ÎÊý£ºusername,waynezheng¡£×¢Ò⣬Ãû×ÖºÍÖµ¶¼²»ÄÜ°üº¬¿Õ°××Ö·ûÒÔ¼°ÏÂÁÐ×Ö·û£º@ : ;? , " / [ ] ( ) =
¡¡¡¡´¦ÀíCookieµÄÊôÐÔ
¡¡¡¡¿´µ½ÕâÀÓеÄÅóÓÑÓÖÒªÎÊÁË£ºÎÒ¹âÖªµÀÈçºÎ´´½¨CookieÓÐʲôÓÃѽ£¿ÊÇѽ£¬¹âÖªµÀÈçºÎ´´½¨Cookie¶ø²»ÖªµÀÔõôʹÓÃÊDz»¹»µÄ¡£
ÔÚJSPÖУ¬³ÌÐòÊÇͨ¹ýcookie.setXXXÉèÖø÷ÖÖÊôÐÔ£¬ÓÃcookie.
Ïà¹ØÎĵµ£º
×î½üÊÕµ½Ò»¸öÏîÄ¿µÄÔ´´úÂ룬²¿ÊðÒÔºó´ò¿ªÒ³Ãæ·¢ÏÖJSPÒ³ÃæÖеÄEL±í´ïʽ¶¼Ã»ÓнâÎö£¬¶¼ÊÇÔÑùÏÔʾ¡£
ÉÏÍøËÑË÷ÁËÒ»ÏÂÔÒò£¬ÔÀ´ÊÇServlet°æ±¾µÄÎÊÌâ¡£ÔÀ´ServletÖпÉÒÔÉ趨ÊÇ·ñ½âÎöEL±í´ïʽ£¬Ö»ÓÐ2.4°æ±¾µÄServletĬÈÏÊǽâÎöEL±í´ïʽµÄ£¬¶øÆäËû°æ±¾ÊÇĬÈϲ»½âÎöEL±í´ïʽ£¬²éÁËһϳÌÐò£ ......
Ä¿Ç°ÔÚInternetÉϹ㷺ʹÓõĺǫ́¼¼ÊõÖÖÀà·±¶à£¬Ó¦ÓñȽϹ㷺µÄÓÐCGI£¬ASP£¬PHP£¬JSP/JavaServlet£¬ColdFusionµÈ¡£ÔÚÕâÒ»½ÚÀÖ÷Òª½éÉܼ¸ÖÖÔÚ¹úÄÚÓ¦ÓñȽϹ㷺µÄºǫ́ÓïÑÔ¡£
¡¡¡¡CGI£¬È«³ÆΪCommon Gateway Interface
¡¡¡¡CGI¾ÍÊǹ«¹²Íø¹Ø½Ó¿Ú (Common Gateway Interface) µÄËõд¡£ËüÊÇ×îÔç±»ÓÃÀ´½¨Á¢¶¯Ì¬ÍøÕ¾µÄºǫ́¼¼Êõ ......
request, reponse, out, session, application, config, pagecontext, page, exception.
Ò».request¶ÔÏ󣺸öÔÏó·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬Í¨¹ýµ÷ÓøöÔÏóÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»ÐÅÏ¢¡£
1.Request¶ÔÏó¿ÉÒÔʹÓÃgetParameter(string s)·½·¨»ñÈ¡¸Ã±íµ¥Í¨¹ýtextÌá½»µÄÐÅÏ¢¡£È磺
Requ ......
ÔÚ¸÷ÖÖÍøÒ³ÖÆ×÷¼¼ÊõÂÛ̳ÖУ¬³£³£ÓÐÈËѯÎÊjavascriptÓëJavaÓÐʲôÇø±ð£¬ÉõÖÁÓÐÈËÎóÈÏΪjavascript¾ÍÊÇJava¡£javascriptÓëJavaȷʵÓÐÒ»¶¨µÄÁªÏµ£¬µ«ËüÃDz¢²»ÏñÎÒÃÇÏëÏóµÄÄÇÑùÁªÏµ½ôÃÜ£¬ÉõÖÁ¿ÉÒԿ϶¨µØ˵ËüÃÇÓкܴóµÄÇø±ð¡£
¡¡¡¡Ê²Ã´ÊÇJavaScript £¿
¡¡¡¡JavaScript ÊÇ¶Ô ECMA 262 Ó ......
1.²¿ÊðÈýÖÖ·½Ê½£º
(1) ÔÚserver.xmlµÄHost±êÇ©ÄÚн¨Ò»¸öContext±êÇ©
<Context path="/learn1" reloadable="true" docBase="E:\work\tech\project\learn1\WebRoot" workDir="E:\work\tech\project\learn1\WebRoot\work" />
* workDirÊÇÖ¸To ......