Use of application objects in the database cache content navigation column

  Abstract: The application object in the database cache content navigation column 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> when preparing database-driven web pages, some stored in the database content rarely changes, such as columns title, category names, and so on, show that the contents of the cache instead of the best frequent Reading database application can be used jsp pages or other object caching methods, as follows: 
<%
  TreeMap list = (TreeMap) application.getAttribute ( "kejie"); / / Reading cache contents 
  If (list == null) (/ / If the content has not cache, the cache 
  List = new TreeMap (); 
  Application.setAttribute ( "kejie" list); / / cache 
  / / Reading database, object data Add TreeMap 
  Rst = db.executeQuery ( "select type_parent_id, parent_name_cn from type_parent order by parent_order_id"); 
  While (Rst.next ()) ( 
  List.put (Rst.getString ( "type_parent_id"), Rst.getString ( "parent_name_cn")); 
  ) 
  ) 
  <table Width="666" border="0"> <tr> <td width="386" valign="top"> Set entries = list.entrySet (); 
  Iterator iter = entries.iterator (); 

  While (iter.hasNext ()) (/ / cache read and display the contents 

  Map.Entry entry = (Map.Entry) iter.next (); 
  String key = (String) entry.getKey (); 
  String value = (String) entry.getValue (); 
  Out.print (""); 
  Out.print (value); 
  Out.print (""); 
  Out.println ( ""); 

  ) 

  %> </ Td> <td width="270"> </ 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