Java Web µÚÎåÌì Web״̬¹ÜÀí
Ò»¡¢
ΪʲôҪ
Web
״̬¹ÜÀí
¶ÔÓÚÿ¸öÈÝÆ÷¶øÑÔÿ¸öÇëÇó¶¼Ï൱ÓÚÒ»¸öеĿͻ§£¬ÒòΪµ±·þÎñÆ÷Éú³É
Response
·µ»Øµ½¿Í»§¶Ë£¬ÔÚ¿Í»§¶ËÏÔʾ³öÀ´ºóÏà¶ÔÓ¦µÄ
Socket
¾Í»á¹Ø±Õ£¬ËùÒÔ
HTTP
ÐÒéÊǸöÎÞ״̬µÄÐÒ飬Ëû²»Äܱ£´æµ±Ç°Óû§µÄÐÅÏ¢¡£
¶þ¡¢
ʵÏÖ״̬¹ÜÀíµÄ·½Ê½
1.
ÔÚÍøÒ³ÖÐ±íµ¥ÖÐÌí¼ÓÒþ²Ø×Ö¶Î
ȱµã£ºÐèҪÿ´ÎÔÚ
Servlet
Öж¯Ì¬Éú³ÉÕâÖÖÒþ²Ø×ֶΡ£
2.
ÀûÓÃ
Cookie
ȱµã£ºËùÓеÄÐÅÏ¢¶¼±£´æÔÚ¿Í»§¶Ë£¬²»°²È«¡£ä¯ÀÀÆ÷¹Ø±Õºó´ú±í×ŵ±Ç°
cookie
¾Í¹ýÆÚÁË¡£
3.
ÀûÓÃ
Session
Óŵ㣺ÔÚ¿Í»§¶Ë
cookie
ÖÐÖ»±£´æһЩ²»ÖØÒªµÄÐÅÏ¢£¬±ÈÈç
SessionID
µÈÄÚÈÝ£¬ÖØÒªÐÅÏ¢±£´æÔÚ·þÎñÆ÷¶Ë£¬ÕâÑù°²È«¡£¶øÇÒµ±¿Í»§¶Ë½ûÓÃÁË
cookie
ºóÄܹ»ÀûÓÃ
URL
ÖØдʵÏÖ¡£µ±¿Í»§¶Ë¹Ø±Õºó·þÎñÆ÷¶ËµÄ
Session
²»»áÏú»Ù¡£
Èý¡¢
Cookie
Cookie coo = new
Cookie(“xzw”,” 2005”);
response.addCookie(coo);
coo.getMaxAge(5);
ËÄ¡¢
Session
ͨ¹ý
request.getSession()
´´½¨
Session
¶ÔÏó£¬Í¨¹ý
invalidate()
ʹ
Session
ʧЧ¡£
Îå¡¢
URL
ÖØд
Web
·þÎñÆ÷»á×Ô¶¯µ÷ÓÃ
Cookie
ºÍ
URL
ÖØд£¬µ±¿Í»§¶Ë½ûÓÃ
cookie
ºó»á×Ô¶¯µ÷ÓÃ
URL
ÖØд¡£
String str = response.encodeURL(“url”);
response.sendRirect(str);
Ïà¹ØÎĵµ£º
ÔÎÄÒý×Ôhttp://hi.baidu.com/heyinjie/blog/item/608ee7108f1f4802203f2e35.html
´ò¸ö±È·½£ºÒ»¸öobject¾ÍÏñÒ»¸ö´ó·¿×Ó£¬´óÃÅÓÀÔ¶´ò¿ª¡£·¿×ÓÀïÓкܶ෿¼ä£¨Ò²¾ÍÊÇ·½·¨£©¡£ÕâЩ·¿¼äÓÐÉÏËøµÄ£¨synchronized·½·¨£©£¬ ºÍ²»ÉÏËøÖ®·Ö£¨ÆÕͨ·½·¨£©¡£·¿ÃÅ¿Ú·Å×ÅÒ»°ÑÔ¿³×£¨key£©£¬Õâ°ÑÔ¿³×¿ÉÒÔ´ò¿ªËùÓÐÉÏËøµÄ·¿¼ä¡£ÁíÍâÎÒ°ÑËùÓÐÏë ......
³õѧJAVA£¬ºÃ²»ÈÝÒ×½â¾öÁËÕâ¸öÊý¾Ý¿âÁ¬½ÓÎÊÌ⣬Õâ¸öÖ÷ÒªÊÇÓÐÁ½¸öÎÊÌ⣬һ¸öÊÇJDBC-odbcµÄÎÊÌ⣬Èç¹ûûÓнâ¾öºÃÊý¾ÝÔ´ÅäÖ㬾ø¶ÔÊÇÓÐÈÝÒ׳öÎÊÌâµÄ£¬¼ÙÉèÄãʹÓõÄÊÇaccessµÄÊý¾Ý¿â£¬ÕâÊÇÍøÉϵÄÒ»¸öÀý×ÓµÄÓï¾ä
String dburl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=database.mdb";
Æäʵ²¢²»ÐèÒªÄÇô³¤£¬¼Ù ......
Ò»¡¢
ΪʲôҪʹÓÃ
JSP
ÔÚ¿Í»§¶ËÍøÒ³±à³ÌÖÐ
Java
µÄ½â¾ö·½°¸ÊÇ
Servlet/JSP
¡£¶ÔÓÚ¶¯Ì¬Ò³ÃæµÄÐγÉÎÒÃÇ¿ÉÒÔÀûÓÃÔÚ
Servlet
Öбàд×Ö·û´®ÊµÏÖ£¬µ«ÊÇÕâÑù»áʹ³ÌÐòÔ±µÄ¹¤×÷±äµÃÒì³£µÄ·±Ëö£¬ËùÒÔÎÒÃDzÉÓÃ
JSP
´ïµ½ÍøÒ³µÄ¶¯Ì¬ÏÔʾ¡£
¶þ¡¢
ʲôÊÇ
JSP
JSP
£¨
JavaServerPage
£©ºÍ
Servlet
ÊÇ
Java
ÖвúÉú¶¯Ì ......
5.
JSP
±ê×¼¶¯×÷¡¢
JSP
Ö¸ÁîÓÃÓÚÒ³ÃæÓëÈÝÆ÷¼äµÄͨÐÅ£¬¶ø
JSP
±ê×¼¶¯×÷ÓÃÓÚÒ³ÃæÓëÒ³Ãæ»òÕßÒ³ÃæÓë×é¼þ¼äµÄͨÐÅ¡£È磺
<jsp:include
page=”localURL” flush=”true”>
6.
JSP
Òþʽ¶ÔÏó
ÔÚ
......
Ò»¡¢
GET
ºÍ
POST
µÄÇø±ð
1.GET
Ìá½»µÄÊÇÎı¾ÄÚÈÝ£¬¹æ¶¨ÆäÊý¾Ý³¤¶È²»³¬¹ý
255
¸ö×Ö·û¡£ÔÚ
GET
·½Ê½Ìá½»µÄ
URL
ÖлáÏÔʾ³öÌá½»µÄ²éѯÊý¾Ý¶øÈ´Ìá½»Êý¾ÝµÄ»º´æ»áÔÚä¯ÀÀÆ÷µÄ
URL
Àúʷ״̬ÖУ¬ÕâÑùÎÒÃÇÍùÍùÔÚä¯ÀÀÍøÒ³µÄʱºòµã»÷ºóÍ˼ü²»ÐèÒªÖØз¢ËÍÇëÇó¡£
2.POST
Ìá½»µÄ¿ÉÒÔʹÎı¾ÄÚÈÝ£¬Ò²¿ÉÒÔʹ¶þ½øÖÆÄÚÈÝ£¬Ëù ......