Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¹ØÓÚjspÖеÄcookieС³ÌÐò

<body>
 <%
   Cookie[] cookies = request.getCookies() ;
   Cookie cookie = null ;
   if(cookies!=null){
     cookie = cookies[0] ;
     out.print("ÉϴηÃÎʵÄipÊÇ£º " + request.getRemoteAddr() +"<br>") ;  //µÃµ½¿Í»§¶ËµÄip
     out.print("ÉϴηÃÎÊʱ¼ä£º" + cookie.getValue()) ;
     cookie.setValue(new java.util.Date().toString()) ;
     response.addCookie(cookie) ;         //±£´æµ½¿Í»§¶Ë
     cookie.setMaxAge(365 * 24 * 3600);
   }
  
  
   if(cookies==null){
     cookie = new Cookie("AccessTime","") ;
     cookie.setValue(new java.util.Date().toString()) ;
     response.addCookie(cookie) ;    //±£´æµ½¿Í»§¶Ë
     cookie.setMaxAge(365 * 24 * 3600);
   }
  %>
  </body>
ps£ºÈç¹ûûÓÐÉèÖÃcookieµÄÓÐЧÆÚ£¬ÄÇôÔڹرÕä¯ÀÀÆ÷ʱcookie»á±»É¾³ý¡£Èç¹ûÉúÃüÆÚΪ¸ºÕûÊý£¬±íʾÕâ¸öcookie¶ÔÏóÊÇÁÙʱµÄ£¬²»Òª±£´æÔÚÓ²ÅÌÖУ¬¹Ø±Õä¯ÀÀÆ÷ºóÊý¾Ý»á×Ô¶¯¶ªÊ§£¡


Ïà¹ØÎĵµ£º

JSPÖÐÎÄÂÒÂë´¦Àí°ì·¨ תÔصģ¬ºÃ³¤°¡~~~

jspÖÐÎÄÏÔʾÂÒÂë½â¾ö·½°¸2006-12-27 22:56
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Ó
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾­³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½
µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾Í³öÏÖÂÒ ......

×éÆ´jsp·½·¨2

<html:html>
<HEAD>
<tiles:insert attribute="header" />
</HEAD>
<body>
<tiles:insert attribute="top" />
<table width="100%" height="400" border="0" align="center"
 cellpadding="0" cellspacing="0">
 <tr>
  <td width="178" ......

×éÆ´jsp·½·¨3

<table width=100% border="0" align="center" cellpadding="0"
 cellspacing="0">
 <tr>
  <td height="1" class="gray1"></td>
 </tr>
</table>
<tiles:insert attribute="footer" />
</body>
</html:html> ......

¿´V512ÊÓƵJsp/Servletѧϰ±Ê¼Ç

//ѧϰ±Ê¼Ç, ¿ÉÄÜÓÐЩµØ·½Àí½âÓÐÎó, »á±í´ï²»Çå³þ
        v512_servlet+jsp
01 ÔÚÐÞ¸ÄÍêCookieºó,Ò»¶¨Òª¼ÓÉÏresponse.addCookie(c);
   CookieÖÐÖ»Äܱ£´æ×Öĸ»òÊý×ÖÐÅÏ¢;
02 req.getSession()Óëreq.getSession(boolean create)
   ÎÞ²ÎÊýµÄ == ÓвÎÊýµÄ²ÎÊýÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ