jspµÄsessionÏê½â
http://www.egzcn.com/article/webbc/JSP/2006-03-22/2003.html À´Ô´
ÕªÒª£ºËäÈ»session»úÖÆÔÚwebÓ¦ÓóÌÐòÖб»²ÉÓÃÒѾºÜ³¤Ê±¼äÁË£¬µ«ÊÇÈÔÈ»ÓкܶàÈ˲»Çå³þsession»úÖƵı¾ÖÊ£¬ÒÔÖÁ²»ÄÜÕýÈ·µÄÓ¦ÓÃÕâÒ»¼¼Êõ¡£±¾ÎĽ«ÏêϸÌÖÂÛsessionµÄ¹¤×÷»úÖƲ¢ÇÒ¶ÔÔÚJava web applicationÖÐÓ¦ÓÃsession»úÖÆʱ³£¼ûµÄÎÊÌâ×÷³ö½â´ð¡£
Ŀ¼£º
Ò»¡¢ÊõÓïsession
¶þ¡¢HTTPÐÒéÓë״̬±£³Ö
Èý¡¢Àí½âcookie»úÖÆ
ËÄ¡¢Àí½âsession»úÖÆ
Îå¡¢Àí½âjavax.servlet.http.HttpSession
Áù¡¢HttpSession³£¼ûÎÊÌâ
Æß¡¢¿çÓ¦ÓóÌÐòµÄsession¹²Ïí
°Ë¡¢×ܽá
²Î¿¼Îĵµ
Ò»¡¢ÊõÓïsession
ÔÚÎҵľÑéÀsessionÕâ¸ö´Ê±»ÀÄÓõij̶ȴó¸Å½ö´ÎÓÚtransaction£¬¸ü¼ÓÓÐȤµÄÊÇtransactionÓësessionÔÚijЩÓᄈϵĺ¬ÒåÊÇÏàͬµÄ¡£
session£¬ÖÐÎľ³£·ÒëΪ»á»°£¬Æä±¾À´µÄº¬ÒåÊÇÖ¸ÓÐʼÓÐÖÕµÄһϵÁж¯×÷/ÏûÏ¢£¬±ÈÈç´òµç»°Ê±´ÓÄÃÆðµç»°²¦ºÅµ½¹Ò¶Ïµç»°ÕâÖмäµÄһϵÁйý³Ì¿ÉÒÔ³Æ֮Ϊһ¸ö session¡£ÓÐʱºòÎÒÃÇ¿ÉÒÔ¿´µ½ÕâÑùµÄ»°“ÔÚÒ»¸öä¯ÀÀÆ÷»á»°Æڼ䣬...”£¬ÕâÀïµÄ»á»°Ò»´ÊÓõľÍÊÇÆä±¾Ò壬ÊÇÖ¸´ÓÒ»¸öä¯ÀÀÆ÷´°¿Ú´ò¿ªµ½¹Ø±ÕÕâ¸öÆÚ¼ä ¢Ù¡£×î»ìÂÒµÄÊÇ“Óû§£¨¿Í»§¶Ë£©ÔÚÒ»´Î»á»°ÆÚ¼ä”ÕâÑùÒ»¾ä»°£¬Ëü¿ÉÄÜÖ¸Óû§µÄһϵÁж¯×÷£¨Ò»°ãÇé¿öÏÂÊÇͬij¸ö¾ßÌåÄ¿µÄÏà¹ØµÄһϵÁж¯×÷£¬±ÈÈç´ÓµÇ¼µ½Ñ¡¹ºÉÌÆ·µ½½áÕ˵dzöÕâÑùÒ»¸öÍøÉϹºÎïµÄ¹ý³Ì£¬ÓÐʱºòÒ²±»³ÆΪһ¸ötransaction£©£¬È»¶øÓÐʱºòÒ²¿ÉÄܽö½öÊÇÖ¸Ò»´ÎÁ¬½Ó£¬Ò²ÓпÉÄÜÊÇÖ¸º¬Òå¢Ù£¬ÆäÖеIJî±ðÖ»ÄÜ¿¿ÉÏÏÂÎÄÀ´ÍƶϢڡ£
È»¶øµ±sessionÒ»´ÊÓëÍøÂçÐÒéÏà¹ØÁªÊ±£¬ËüÓÖÍùÍùÒþº¬ÁË“ÃæÏòÁ¬½Ó”ºÍ/»ò“±£³Ö״̬”ÕâÑùÁ½¸öº¬Ò壬 “ÃæÏòÁ¬½Ó”Ö¸µÄÊÇÔÚͨÐÅË«·½ÔÚͨÐÅ֮ǰҪÏȽ¨Á¢Ò»¸öͨÐŵÄÇþµÀ£¬±ÈÈç´òµç»°£¬Ö±µ½¶Ô·½½ÓÁ˵绰ͨÐŲÅÄÜ¿ªÊ¼£¬Óë´ËÏà¶ÔµÄÊÇдÐÅ£¬ÔÚÄã°ÑÐÅ·¢³öÈ¥µÄʱºòÄã²¢²»ÄÜÈ·È϶Է½µÄµØÖ·ÊÇ·ñÕýÈ·£¬Í¨ÐÅÇþµÀ²»Ò»¶¨Äܽ¨Á¢£¬µ«¶Ô·¢ÐÅÈËÀ´Ëµ£¬Í¨ÐÅÒѾ¿ªÊ¼ÁË¡£“±£³Ö״̬”ÔòÊÇָͨÐŵÄÒ»·½Äܹ»°ÑһϵÁеÄÏûÏ¢¹ØÁªÆðÀ´£¬Ê¹µÃÏûÏ¢Ö®¼ä¿ÉÒÔ»¥ÏàÒÀÀµ£¬±ÈÈçÒ»¸ö·þÎñÔ±Äܹ»ÈϳöÔٴιâÁÙµÄÀϹ˿Ͳ¢ÇҼǵÃÉÏ´ÎÕâ¸ö¹Ë¿Í»¹Ç·µêÀïÒ»¿éÇ®¡£ÕâÒ»ÀàµÄÀý×ÓÓГһ¸öTCP session”»òÕß “Ò»¸öPOP3 session”¢Û¡£
¶øµ½ÁËweb·þÎñÆ÷Å·¢Õ¹µÄʱ´ú£¬sessionÔÚweb¿ª·¢ÓᄈϵÄÓïÒåÓÖÓÐÁËеÄÀ©Õ¹£¬ËüµÄº¬ÒåÊÇÖ¸Ò»ÀàÓÃÀ´ÔÚ¿Í»§¶ËÓë·þÎñÆ÷Ö®¼ä±£³Ö״̬µÄ½â¾ö·½°¸
Ïà¹ØÎĵµ£º
AjaxºÍjspµÄ¹ÖÏÖÏó
Èç¹ûÓÃAjaxÈ¥ÇëÇóÒ»¸öjspÒ³Ã棬¸ÃjspÒ³Ãæ·µ»ØµÄÊÇxml£¨response.setContentType("text/xml; charset=GB2312");£©£¬²¢ÇÒ¸Ãjsp°üº¬ÏÂÃæÕâЩͷ@pageÖ¸ÁîµÄ»°£¬ÔòÔÚ¿Í»§¶Ëxml=XMLHttpRequest.responseXMLµÃµ½µÄÊÇÒ»¸ö²»°üº¬ÈÎÎñ¶«Î÷µÄxml¶ÔÏ󣬼´xml.childNodes.length½«»áÊÇ0.
......
Login.java
/******************************************************/
×¢Ò⣺ÓÉÓÚÔÚjspÖд´½¨Cookieʱ£¬±ØÐë±£Ö¤Cookie´´½¨Óï¾äдÔÚjspÒ³ÃæÍ·²¿µÄ<jsp:include page="includes\head.jsp" flush="true" />±êǩ֮ǰ²Å»áÉúЧ£¬·ñÔòÊÖ¶¯Ìí¼ÓµÄCookieʧ°Ü¡£
ËùÒÔÎÒ¾ö¶¨½²´´½¨CookieÓï¾ä·ÅÔÚservl ......
¾³£¿´µ½jspµÄ³õѧÕßÎÊtomcatÏÂÈçºÎÅäÖÃjsp¡¢servletºÍbeanµÄÎÊÌ⣬ÓÚÊÇ×ܽáÁËÒ»ÏÂÈçºÎtomcatÏÂÅäÖÃjsp¡¢servletºÍben£¬Ï£Íû¶ÔÄÇЩ³õѧÕßÓÐËù°ïÖú¡£
µÚÒ»²½£ºÏÂÔØj2sdkºÍtomcat£ºµ½sun¹Ù·½Õ¾µã£¨http://java.sun.com/j2se/1.4.2/download.html£©ÏÂÔØj2sdk£¬×¢ÒâÏÂÔذ汾ΪWindows Offline InstallationµÄSDK£¬Í¬Ê±×îºÃÏ ......
×î»ù±¾µÄÂÒÂëÎÊÌâ
Õâ¸öÂÒÂëÎÊÌâÊÇ×î¼òµ¥µÄÂÒÂëÎÊÌâ¡£Ò»°ãлá³öÏÖ¡£¾ÍÊÇÒ³Ãæ±àÂë²»Ò»Öµ¼ÖµÄÂÒÂë¡£
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=iso8859-1"%>
<html>
<head>
<title>ÖÐÎÄÎÊÌâ</title>
<meta http-equiv="Co ......