Cookie read and write Chinese in a way

  Abstract: Cookie read and write Chinese in a way 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="171" height="86" align="center" valign="top"> </ td> <td width="519" valign="top"> 

  Cookie read and write Chinese in a way. 

  First, Cookie wrote to the Chinese Information: addCookie.jsp 
  <% @ Page import = "java.net .*" contentType = "text / html; gb2312 charset ="%> 
<%
  Cookie cookie = 
  New Cookie (URLEncoder.encode ( "name"), URLEncoder.encode ( "web enthusiasts")); 
  Response.addCookie (cookie); 
%>
OK!

  Second, the Chinese read Cookie information ReadCookie.jsp 

  <% @ Page import = "java.net .*" contentType = "text / html; gb2312 charset ="%> 
<%
  Cookie rcookie [] = request.getCookies (); 

  If (rcookie == null) 
  Out.print ( "Reading less than cookie"); 
  Else ( 
  For (int i = 0; i <rcookie.length; i + +) ( 
  If (URLDecoder.decode (rcookie [i]. GetName ()). Equals ( "name")) ( 
  Out.print (URLDecoder.decode (rcookie [i]. GetName ())+"=" 
  + URLDecoder.decode (rcookie [i]. GetValue ())); 
  ) 
  ) 
  ) 
%>

  </ Td> </ tr> <tr> <td height="20" colspan="2"> 

  </ Td> </ tr> </ table> </ td> </ tr> <tr> 

  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: ,

Releated Java Articles

Comments

Leave a Reply