<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Berthou.com &#187; source</title>
	<atom:link href="https://www.berthou.com/us/tag/source/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.berthou.com/us</link>
	<description>A french developper blog</description>
	<lastBuildDate>Mon, 09 Aug 2010 08:55:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>MemoryTable &#8211; To simplify the values listes gestion</title>
		<link>https://www.berthou.com/us/2008/02/09/memorytable-to-simplify-the-values-listes-gestion/</link>
		<comments>https://www.berthou.com/us/2008/02/09/memorytable-to-simplify-the-values-listes-gestion/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 13:16:51 +0000</pubDate>
		<dc:creator>rberthou</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.berthou.com/us/2008/02/09/memorytable-to-simplify-the-values-listes-gestion/</guid>
		<description><![CDATA[Description Usually in software devellopement we use values liste that we take from &#8220;properties&#8221;, SQL tables or in the worst case, &#8220;in hard codding&#8221; in our application. As many people I had this problem ans I solve it by creating &#8220;Tables Memories&#8221;. It permits me to limit the access to the database (or file), to [...]]]></description>
				<content:encoded><![CDATA[<h2 class="titre2">Description</h2>
<p>Usually in software devellopement we use values liste that we take from &#8220;properties&#8221;, SQL tables or in the worst case, &#8220;in hard codding&#8221; in our application.</p>
<p>As many people I had this problem ans I solve it by creating &#8220;Tables Memories&#8221;. It permits me to limit the access to the database (or file), to low the occupation memory by having just one request of these memories liste, and to simplify my code.</p>
<p>This code is quite old and could be improved (use of the patern singleton instead of a full static classe, synchronize optimisation&#8230;). I use this in a huge number of project and I always report these modifications because I don&#8217;t have any performance or memories problems.</p>
<h2 class="titre2">Fonctions</h2>
<p>During the cration of this componant I wanted to have the following functions also I simplify in maximum its use in a JSP page or a Servtel :</p>
<ul>
<li>&#8220;Connection&#8221; sql connection outside bean</li>
<li>Do not reload the data  if they are already in memory</li>
<li>Load of a liste from a select SQL : loadQuery(&#8230;)</li>
<li>Load of a list from a values liste : loadListe(&#8230;)</li>
<li>Read of the description associated to a code (String) : getValue(&#8230;)</li>
<li>Read of the description associated to a code (Combobox) : getListe(&#8230;)</li>
<li>Read of the description associated to a code (Radio Bouton) : getRadio(&#8230;)</li>
</ul>
<p><span id="more-36"></span></p>
<h2 class="titre2">Download</h2>
<p class="alertDownload">
<a href="/download.php?type=java&#038;file=memorytable.zip">memorytable.zip</a>
</p>
<h2 class="titre2">Use</h2>
<p>This little sample of a code (jsp) show how to do the load (initialisation) of the &#8220;Memory Table&#8221;.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>@ page language<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;java&quot;</span> <span style="color: #000000; font-weight: bold;">import</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;com.berthou.sql.*&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>
java.<span style="color: #006633;">sql</span>.<span style="color: #003399;">Connection</span> conn <span style="color: #339933;">=</span> .... <span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Initialize you connection</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Load a hard coded liste</span>
MemoryTable.<span style="color: #006633;">loadListe</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;TEST_L_ETAT&quot;</span>,<span style="color: #0000ff;">&quot;    = ;V=Valide;E=En erreur;I=Incomplete;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Load a SQL Query liste</span>
<span style="color: #666666; font-style: italic;">// Research of the service code and of the description of the actifs service.</span>
<span style="color: #003399;">String</span> sql <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select cdserv, libelle from service where status = 'O' &quot;</span> <span style="color: #339933;">;</span>
MemoryTable.<span style="color: #006633;">loadQuery</span><span style="color: #009900;">&#40;</span>conn, <span style="color: #0000ff;">&quot;TBL_SERV&quot;</span>,sql <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #339933;">%&gt;</span></pre></td></tr></table></div>

<p>When this load has been made you can use at once the &#8220;memory tables&#8221;</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>@ page language<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;java&quot;</span> <span style="color: #000000; font-weight: bold;">import</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;com.berthou.sql.*&quot;</span><span style="color: #339933;">%&gt;</span>
....
<span style="color: #339933;">&lt;%</span> <span style="color: #003399;">String</span> service <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;1305&quot;</span> <span style="color: #339933;">;</span> <span style="color: #339933;">%&gt;</span>
Service <span style="color: #339933;">:</span> <span style="color: #339933;">&lt;%=</span>service<span style="color: #339933;">%&gt;</span> <span style="color: #339933;">-</span> <span style="color: #339933;">&lt;%=</span>MemoryTable.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;TBL_SERV&quot;</span>, service<span style="color: #009900;">&#41;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #009900;">&#40;</span>affiche Service <span style="color: #339933;">:</span> <span style="color: #cc66cc;">1305</span> <span style="color: #339933;">-</span> Libelle du service1305<span style="color: #009900;">&#41;</span>
&nbsp;
Service <span style="color: #339933;">:</span>
<span style="color: #339933;">&lt;</span>select name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;service&quot;</span><span style="color: #339933;">&gt;&lt;%=</span>MemoryTable.<span style="color: #006633;">getListe</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;TBL_SERV&quot;</span>, service<span style="color: #009900;">&#41;</span><span style="color: #339933;">%&gt;&lt;/</span>select<span style="color: #339933;">&gt;</span>
<span style="color: #009900;">&#40;</span>build a combobox by activating the asked service<span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<h2 class="titre2">The MemoryTable class</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.berthou.sql</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Connection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.ResultSet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.ResultSetMetaData</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.SQLException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Statement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Hashtable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.StringTokenizer</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Vector</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author rberthou
 *
 * Creating 3 févr. 2001
 * Package  com.berthou.sql
 * Projet   tools
 * -------+------------+-------------------------------------------------------------------------
 *   Ver  | Date       | Comments
 * -------+------------+-------------------------------------------------------------------------
 *  2.00  | 04/04/2006 | List's add and radio button (+ comments)
 *  1.00  | 03/02/2001 | Creation
 * -------+------------+-------------------------------------------------------------------------
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MemoryTable <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger logger <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>MemoryTable.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">Hashtable</span> h <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Hashtable</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Reload of the data of a guery
	 *
	 * @param Connection
	 *            conn : used connection
	 * @param String
	 *            tableName : Name of the Query
	 * @param String
	 *            Sql : Ordre SQL à executer
	 * @param boolean
	 *            tr : true if trim colonne code
	 *
	 * @return int rc : nombre d'enregistrements chargés
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">int</span> reloadQuery<span style="color: #009900;">&#40;</span><span style="color: #003399;">Connection</span> conn,
			<span style="color: #003399;">String</span> tableName, <span style="color: #003399;">String</span> sql, <span style="color: #000066; font-weight: bold;">boolean</span> tr<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/* Si la table est déja chargé on la recharge */</span>
		freeTable<span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> loadQuery<span style="color: #009900;">&#40;</span>conn, tableName, sql, tr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * rechargement des données d'un query
	 *
	 * @param Connection
	 *            conn : Connexion utilisée
	 * @param String
	 *            tableName : Nom du Query
	 * @param String
	 *            Sql : Ordre SQL à executer
	 *
	 * @return int rc : nombre d'enregistrements chargés
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">int</span> reloadQuery<span style="color: #009900;">&#40;</span><span style="color: #003399;">Connection</span> conn,
			<span style="color: #003399;">String</span> tableName, <span style="color: #003399;">String</span> sql<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> reloadQuery<span style="color: #009900;">&#40;</span>conn, tableName, sql, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * chargement des données d'une table
	 *
	 * @param Connection
	 *            conn : Connexion utilisée
	 * @param String
	 *            tableName : Nom du Query
	 * @param String
	 *            Sql : Ordre SQL à executer
	 *
	 * @return int rc : nombre d'enregistrements chargés
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">int</span> loadQuery<span style="color: #009900;">&#40;</span><span style="color: #003399;">Connection</span> conn, <span style="color: #003399;">String</span> queryName,
			<span style="color: #003399;">String</span> sql<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> loadQuery<span style="color: #009900;">&#40;</span>conn, queryName, sql, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * chargement des données d'une table
	 *
	 * @param Connection
	 *            conn : Connexion utilisée
	 * @param String
	 *            tableName : Nom du Query
	 * @param String
	 *            Sql : Ordre SQL à executer
	 * @param boolean
	 *            isTrim : Vrai si colonne code a trim
	 *
	 * @return int rc : nombre d'enregistrements chargés
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">int</span> loadQuery<span style="color: #009900;">&#40;</span><span style="color: #003399;">Connection</span> conn, <span style="color: #003399;">String</span> queryName,
			<span style="color: #003399;">String</span> sql, <span style="color: #000066; font-weight: bold;">boolean</span> isTrim<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isLoaded<span style="color: #009900;">&#40;</span>queryName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Vector</span><span style="color: #009900;">&#41;</span> h.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>queryName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> rc <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Vector</span> v <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Vector</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">Statement</span> stmt <span style="color: #339933;">=</span> conn.<span style="color: #006633;">createStatement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">/* Execution */</span>
			<span style="color: #003399;">ResultSet</span> rs <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span>sql<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rs <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">ResultSetMetaData</span> rsdt <span style="color: #339933;">=</span> rs.<span style="color: #006633;">getMetaData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">/* Si utile recherche de la liste des colonnes */</span>
				<span style="color: #000066; font-weight: bold;">int</span> K <span style="color: #339933;">=</span> rsdt.<span style="color: #006633;">getColumnCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">/* Lecture des données et mémorisation dans un Vecteur */</span>
				<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> s <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span>K<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> I <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> I <span style="color: #339933;">&lt;</span> K<span style="color: #339933;">;</span> I<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>I <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;&amp;</span> isTrim<span style="color: #009900;">&#41;</span>
							s<span style="color: #009900;">&#91;</span>I<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>I<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">else</span>
							s<span style="color: #009900;">&#91;</span>I<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>I<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					rc<span style="color: #339933;">++;</span>
					v.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #666666; font-style: italic;">/* Ajout de ce Vecteur dans la HashTable */</span>
				h.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>queryName, v<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				rs.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			stmt.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">SQLException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			logger
					.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unable to fetch table [&quot;</span> <span style="color: #339933;">+</span> queryName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;] err : &quot;</span>
							<span style="color: #339933;">+</span> e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> e<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rc <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Chargement de la table/query [&quot;</span> <span style="color: #339933;">+</span> queryName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;] : &quot;</span>
					<span style="color: #339933;">+</span> rc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> rc<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * rechargement des données d'une liste
	 *
	 * @param String
	 *            tableName : Nom de la liste
	 * @param String
	 *            valeurs : liste des valeurs
	 *
	 * @return int rc : nombre d'enregistrements chargés
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">int</span> reloadListe<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tableName, <span style="color: #003399;">String</span> sql<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/* Si la table est déja chargé on la recharge */</span>
		freeTable<span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> loadListe<span style="color: #009900;">&#40;</span>tableName, sql<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * rechargement des données d'une liste
	 *
	 * @param String
	 *            tableName : Nom de la liste
	 * @param String
	 *            valeurs : liste des valeurs
	 *
	 * @return int rc : nombre d'enregistrements chargés
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">int</span> loadListe<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tableName, <span style="color: #003399;">String</span> sql<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isLoaded<span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Vector</span><span style="color: #009900;">&#41;</span> h.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> rc <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Vector</span> v <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Vector</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">StringTokenizer</span> stoken <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringTokenizer</span><span style="color: #009900;">&#40;</span>sql, <span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/* Lecture des données et mémorisation dans un Vecteur */</span>
		<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>stoken.<span style="color: #006633;">hasMoreElements</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> s <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> token <span style="color: #339933;">=</span> stoken.<span style="color: #006633;">nextToken</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> token.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> token.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// cle</span>
			s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> token.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// valeur</span>
			rc<span style="color: #339933;">++;</span>
			v.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">/* Ajout de ce Vecteur dans la HashTable */</span>
		h.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>tableName, v<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rc <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Chargement de la table/liste [&quot;</span> <span style="color: #339933;">+</span> tableName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;] : &quot;</span>
					<span style="color: #339933;">+</span> rc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> rc<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Nombre de tables chargées
	 *
	 * @return int r : nombre de table
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">int</span> size<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> h.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Test si une table est chargée
	 *
	 * @param String
	 *            tableName : Nom de la table
	 *
	 * @return boolean b : oui ou non...
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">boolean</span> isLoaded<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tableName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> h.<span style="color: #006633;">containsKey</span><span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * libération d'une table
	 *
	 * @param String
	 *            tableName : Nom de la table
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000066; font-weight: bold;">void</span> freeTable<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tableName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>h.<span style="color: #006633;">containsKey</span><span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			h.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Lecture des données d'une table
	 *
	 * @param String
	 *            tableName : Nom de la table
	 *
	 * @return Vector v : les données
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #003399;">Vector</span> getTable<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tableName<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Vector</span><span style="color: #009900;">&#41;</span> h.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Formatage des données d'une table sous forme d'une combobox
	 *
	 * @param String
	 *            tableName : Nom de la table
	 * @param String
	 *            val : Valeur selectionnée
	 *
	 * @return String s : les données (format : &amp;lt;option ... )
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #003399;">String</span> getListe<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tableName, <span style="color: #003399;">String</span> val<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">StringBuffer</span> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Vector</span> v <span style="color: #339933;">=</span> getTable<span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> K <span style="color: #339933;">=</span> v.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> s<span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> I <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> I <span style="color: #339933;">&lt;</span> K<span style="color: #339933;">;</span> I<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				s <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> v.<span style="color: #006633;">elementAt</span><span style="color: #009900;">&#40;</span>I<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #006633;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
						sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;option value=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">+</span> s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> selected&gt;&quot;</span>
								<span style="color: #339933;">+</span> s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">else</span>
						sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;option value=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">+</span> s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">+</span> s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>
								<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Formatage des données d'une table sous forme de radio boutons
	 *
	 * @param String :
	 *            Nom de la zone HTML (name = )
	 * @param String
	 *            tableName : Nom de la table
	 * @param String
	 *            val : Valeur selectionnée
	 * @param String
	 *            after : Le code html a ajouter apres chaque ligne
	 *            (&amp;lt;br/&amp;gt;)
	 *
	 * @return String s : les données (format : &amp;lt;option ... )
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #003399;">String</span> getRadio<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> nm, <span style="color: #003399;">String</span> tableName,
			<span style="color: #003399;">String</span> val, <span style="color: #003399;">String</span> after<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">StringBuffer</span> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Vector</span> v <span style="color: #339933;">=</span> getTable<span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>after <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
			after <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> K <span style="color: #339933;">=</span> v.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> s<span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> I <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> I <span style="color: #339933;">&lt;</span> K<span style="color: #339933;">;</span> I<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				s <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> v.<span style="color: #006633;">elementAt</span><span style="color: #009900;">&#40;</span>I<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #006633;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;input type=<span style="color: #000099; font-weight: bold;">\&quot;</span>RADIO<span style="color: #000099; font-weight: bold;">\&quot;</span> name=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">+</span> nm <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> id=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>
							<span style="color: #339933;">+</span> nm <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> value=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">+</span> s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
						sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&gt;&quot;</span> <span style="color: #339933;">+</span> s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/input&gt;&quot;</span> <span style="color: #339933;">+</span> after<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Lecture d'une valeur
	 *
	 * @param String
	 *            tableName : Nom de la table
	 * @param String
	 *            val : Valeur selectionnée
	 *
	 * @return String s : le libelle
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #003399;">String</span> getValue<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tableName, <span style="color: #003399;">String</span> val<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> r <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Vector</span> v <span style="color: #339933;">=</span> getTable<span style="color: #009900;">&#40;</span>tableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> K <span style="color: #339933;">=</span> v.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> s<span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> I <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> I <span style="color: #339933;">&lt;</span> K<span style="color: #339933;">;</span> I<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				s <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> v.<span style="color: #006633;">elementAt</span><span style="color: #009900;">&#40;</span>I<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #006633;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						r <span style="color: #339933;">=</span> s<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> r<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>https://www.berthou.com/us/2008/02/09/memorytable-to-simplify-the-values-listes-gestion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>aTicker &#8211; applet</title>
		<link>https://www.berthou.com/us/2007/12/18/aticker-applet/</link>
		<comments>https://www.berthou.com/us/2007/12/18/aticker-applet/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 21:51:57 +0000</pubDate>
		<dc:creator>rberthou</dc:creator>
				<category><![CDATA[applet]]></category>
		<category><![CDATA[exemple]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.berthou.com/us/2007/12/18/aticker-applet/</guid>
		<description><![CDATA[Description aTicker is a simple, free and small Ticker texte scrolling Applet. aTicker runs on all browsers with JDK 1.1x support. (aTicker is free with all source code). This applet is available in JDK 1.1x Source HTML &#60;applet codebase="/jar" archive="applet-aticker.jar" code="com.berthou.applet.aticker.aticker.class" width=220 height=20 mayscript&#62; &#60;param name=file value="s"&#62; &#60;param name=cSep value="§"&#62; &#60;param name="speed" value="1"&#62; &#60;param name="delay" [...]]]></description>
				<content:encoded><![CDATA[<h2 class="titre2">Description</h2>
<p>aTicker is a simple, free and small Ticker texte scrolling Applet. aTicker runs on all browsers with JDK 1.1x support. (aTicker is free with all source code).<br />
This applet is available in JDK 1.1x</p>
<p><center><br />
<applet codebase="/jar" archive="applet-aticker.jar" code="com.berthou.applet.aticker.aticker.class" width=220 height=20 MAYSCRIPT></p>
<param name=file value="s">
<param name=cSep value="§">
<param name="speed" value="1">
<param name="delay" value="30">
<param name="local" value="true">
<param name="bgcolor" value="13693183">
<param name="Font1" value="Verdana, 14, 0, 0">
<param name="Font2" value="Verdana, 14, 1, 1220">
<param name="s0" value="JavaSide § http://www.javaside.com § _load">
<param name="s1" value="Mess 2 § javascript:alert('Salut...') § _script § ?PopupJavascript">
<param name="s2" value="berthou-fr § http://www.berthou.com/fr/ § _load">
<param name="s3" value="berthou-us § http://www.berthou.com/us/ § _load">
</applet></p>
<p></center></p>
<h2 class="titre2">Source HTML</h2>
<pre class="alertCode">
&lt;applet codebase="/jar" archive="applet-aticker.jar" code="com.berthou.applet.aticker.aticker.class" width=220 height=20 mayscript&gt;
	&lt;param name=file value="s"&gt;
	&lt;param name=cSep value="§"&gt;
	&lt;param name="speed" value="1"&gt;
	&lt;param name="delay" value="30"&gt;
	&lt;param name="local" value="true"&gt;
	&lt;param name="bgcolor" value="13693183"&gt;
	&lt;param name="Font1" value="Verdana, 14, 0, 0"&gt;
	&lt;param name="Font2" value="Verdana, 14, 1, 1220"&gt;
	&lt;param name="s0" value="JavaSide § http://www.javaside.com § _load"&gt;
	&lt;param name="s1" value="Mess 2 § javascript:alert('Salut...') § _script § ?PopupJavascript"&gt;
	&lt;param name="s2" value="berthou-fr § http://www.berthou.com/fr/ § _load"&gt;
	&lt;param name="s3" value="berthou-us § http://www.berthou.com/us/ § _load"&gt;
&lt;/applet&gt;
</pre>
<p><span id="more-29"></span></p>
<h2 class="titre2">Parameters</h2>
<table class="tbl0" >
<thead>
<tr class="rh">
<th>Param name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="r1">
<td>file</td>
<td>string</td>
<td>Data file or prefix pour &#8220;line param&#8221;</td>
</tr>
<tr class="r2">
<td>cSep</td>
<td>char</td>
<td>text delimiteur (defaut &#8220;;&#8221;)</td>
</tr>
<tr class="r1">
<td>speed</td>
<td>integer</td>
<td>vitesse de defilement (1)</td>
</tr>
<tr class="r2">
<td>local</td>
<td>String</td>
<td>&#8220;true&#8221; : to read datas in parameters (no external data file)</td>
</tr>
<tr class="r1">
<td>delay</td>
<td>integer</td>
<td>mili-secs entre 2 affichages (100)</td>
</tr>
<tr class="r2">
<td>bgcolor</td>
<td>integer</td>
<td>Background color (en decimal)</td>
</tr>
<tr class="r1">
<td>Font1</td>
<td>String</td>
<td>Definition de la police : Face, Size, Style, color</td>
</tr>
<tr class="r2">
<td>Font2</td>
<td>String</td>
<td>Definition de la police active: Face, Size, Style, color</td>
</tr>
</tbody>
</table>
<h2 class="titre2">Data file</h2>
<p>You can define your data in external file (static or dynamique PHP, ASP, ..) you must remove &#8220;local&#8221; parameter to use an external file</p>
<table class="tbl0">
<thead class="rh">
<tr>
<th>Col</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="r1">
<td>1 Message</td>
<td>string</td>
<td>message</td>
</tr>
<tr class="r2">
<td>2 URL</td>
<td>string</td>
<td>Link URL<br /> si &#8220;&#8211;&#8221; pas de lien</td>
</tr>
<tr class="r1">
<td>3 Target</td>
<td>string</td>
<td>utiliser _script pour un appel javascript</td>
</tr>
<tr class="r2">
<td>4 Status line</td>
<td>String</td>
<td>Message affiché dans la ligne de &#8220;status&#8221;</td>
</tr>
</tbody>
</table>
<h2 class="titre2">Download</h2>
<p class="alertDownload">
<a href="/download.php?type=java&#038;file=aticker.zip">aticker.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.berthou.com/us/2007/12/18/aticker-applet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JVMine &#8211; Minesweeper</title>
		<link>https://www.berthou.com/us/2007/10/21/jvmine-un-classique/</link>
		<comments>https://www.berthou.com/us/2007/10/21/jvmine-un-classique/#comments</comments>
		<pubDate>Sun, 21 Oct 2007 16:54:28 +0000</pubDate>
		<dc:creator>rberthou</dc:creator>
				<category><![CDATA[applet]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.berthou.com/us/?p=12</guid>
		<description><![CDATA[This small applet is a &#34;minesweeper&#34; clone, the goal of the game is very easy, you just have to discover and mark all the mines. To do this you have as option left clic which show you the land (you loose of there is a mine) and right clic which mark a mine (if the [...]]]></description>
				<content:encoded><![CDATA[<p>This small applet is a &quot;minesweeper&quot; clone, the goal of the game is very easy, you just have to discover and mark all the mines. To do this you have as option left clic which show you the land (you loose of there is a mine) and right clic which mark a mine (if the case is not discovered).</p>
<p>For developpers all source code is avaible <a href="/download.php?type=java&file=jvmine.zip">here</a></p>
<p> i have also done a midlet version of this game and I think I am going to propose it to you soon.</p>

<br />
PS : My best score is in expert mode  153 sec.</p>

<span id="more-12"></span>

<div align="center">
<form name="cJVM">
    <input type="button" onclick="newJVM()" value="New Game" />     <select id="jvm_lvl" name="jvm_lvl">
    <option value="1">Debutant</option>
    <option value="1">Moyen</option>
    <option selected="selected" value="3">Expert</option>
    </select>
</form>
<br/>
<applet width="450" height="285" name="JMine" id="JMine" code="com.berthou.applet.game.jvmine.class" archive="/jar/jvmine.jar">
  <param value="/img/j" name="bImg" />
  <param value="12632256" name="bgcolor" />
  <param value="Arial" name="font" />
  <param value="16" name="fontsize" />
</applet>
</p>
</div>

<p>
<ul>
<h3>Download</h3>
<li><a href="/download.php?type=java&file=jvmine.zip">jvmine.zip</a></li>
</ul>
<ul>
<h3>Code html</h3>
<pre langage="HTML">
&lt;applet code=JVMine.class width="450" height="300" /&gt;
	&lt;param name=bImg value="img/j" /&gt;
	&lt;param name=bgcolor value=2222200&gt;
	&lt;param name=nbmine value="10" /&gt;
	&lt;param name=nbcol value="8" /&gt;
	&lt;param name=nbligne value="8" /&gt;
	&lt;param name=font value="Arial" /&gt;
	&lt;param name=fontsize value=14 /&gt;
&lt;/applet>
</pre>
</ul>

</p>

<script language="JavaScript">
function newJVM() {
    var JMine = document.getElementById("JMine") ;
    var sl = document.getElementById("jvm_lvl") ;

    var iM = sl.selectedIndex ;
    if (iM == 0) {
	JMine.m_col    = 8 ;
	JMine.m_ligne  = 8 ;
	JMine.m_mine   = 10 ;
    }
    if (iM == 1) {
	JMine.m_col    = 16 ;
	JMine.m_ligne  = 16 ;
	JMine.m_mine   = 40 ;
    }
    if (iM == 2) {
	JMine.m_col    = 30 ;
	JMine.m_ligne  = 16 ;
	JMine.m_mine   = 99 ;
    }
    JMine.newGame( ) ;
    return ;
   }
</script>
]]></content:encoded>
			<wfw:commentRss>https://www.berthou.com/us/2007/10/21/jvmine-un-classique/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servlet : zipservlet</title>
		<link>https://www.berthou.com/us/2007/09/29/test-english/</link>
		<comments>https://www.berthou.com/us/2007/09/29/test-english/#comments</comments>
		<pubDate>Sat, 29 Sep 2007 09:48:08 +0000</pubDate>
		<dc:creator>rberthou</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[exemple]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://www.berthou.com/us/?p=5</guid>
		<description><![CDATA[This article aims at presenting how to create a servlet that sends a zip file to the user. We create here a html page with a form where you can enter an url. The servlet will get the content of this url (only the html page, not the images or other frames), create a zip [...]]]></description>
				<content:encoded><![CDATA[<p>This article aims at presenting how to create a servlet that sends a zip file to the user. We create here a html page with a form where you can enter an url. The servlet will get the content of this url (only the html page, not the images or other frames), create a zip file with it, and send you the file.<br/>
This example can be used as a basis to do various things.</p>
<ul><li>Sending a file with a servlet<br/>
This involves two headers: Content-Type and Content-Disposition. The content type is set to "application/zip". The other one is used to specify the filename used by the browser when it starts downloading the file.
<pre class="alertCode">
res.setContentType("application/zip");
res.setHeader("Content-Disposition","inline; filename=output.zip;");
</pre>
This header replace "res.setHeader("Content-Disposition","attachment; filename=output.zip;");" (not work with IE5)

In this example, we create a zip file. We'll discuss later on how to create such files. As soon as we get a byte array with the zip file, we are ready to send it.
We simply call out.println(zip) to send the file.
</li>
li>Creating a zip file Have you ever noticed the java.util.zip package ?<br/>
Basically, a zip file is created by adding ZipEntries to a ZipOutputStream.
Once we have create a ZipEntry with a file name, we are ready to write an array of byte to the ZipOutputStream. Then we close the entry, finish the work with a call to finish(). We finally get a String containing the zipped file.
<pre class="alertCode">
zout.putNextEntry(new ZipEntry("file.html"));
zout.write(b,0,size);
zout.closeEntry();
zout.finish();
String zip=bout.toString();
</pre>
<span id="more-5"></span>


<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">javaside.servlet.sample</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* zipservlet.java
*
*  Main class for sample servlet
*
*  @author : R. BERTHOU
*  URL    : http://www.berthou.com/
* -----------------------------------------------------------
* Ver  * Author     *  DATE    * Description
* ....................DD/MM/YY...............................
* 1.00 * R.BERTHOU  * 12/01/01 *
**********************************************************/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.zip.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> zipservlet <span style="color: #000000; font-weight: bold;">extends</span> HttpServlet <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> doGet <span style="color: #009900;">&#40;</span>HttpServletRequest req, HttpServletResponse res<span style="color: #009900;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span>
     <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">byte</span> b<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">300000</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #003399;">URL</span> url<span style="color: #339933;">;</span>
          <span style="color: #003399;">String</span> temp<span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #003399;">ByteArrayOutputStream</span> bout<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #003399;">ZipOutputStream</span> zout<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ZipOutputStream</span><span style="color: #009900;">&#40;</span>bout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          ServletOutputStream out <span style="color: #339933;">=</span> res.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          ServletContext servletContext <span style="color: #339933;">=</span> getServletContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">=</span>req.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;url&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
          <span style="color: #009900;">&#123;</span>
               <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                    url<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span>temp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #003399;">URLConnection</span> uc <span style="color: #339933;">=</span> url.<span style="color: #006633;">openConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #003399;">DataInputStream</span> input <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DataInputStream</span><span style="color: #009900;">&#40;</span>uc.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #000066; font-weight: bold;">int</span> numRead<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">int</span> size<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>numRead <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                         numRead <span style="color: #339933;">=</span> input.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span>b,size,<span style="color: #cc66cc;">20000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                         size<span style="color: #339933;">+=</span>numRead<span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
&nbsp;
                    zout.<span style="color: #006633;">putNextEntry</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ZipEntry</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;file.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    zout.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>b,<span style="color: #cc66cc;">0</span>,size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    zout.<span style="color: #006633;">closeEntry</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    zout.<span style="color: #006633;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #003399;">String</span> zip<span style="color: #339933;">=</span>bout.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                    res.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/zip&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    res.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition&quot;</span>,<span style="color: #0000ff;">&quot;inline; filename=output.zip;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                    out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>zip<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    out.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
               <span style="color: #009900;">&#125;</span>
               <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
               <span style="color: #009900;">&#123;</span>
                    res.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;text/html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;body&gt;&lt;b&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;An error has occured while processing &quot;</span><span style="color: #339933;">+</span>temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Here is the exception: &quot;</span><span style="color: #339933;">+</span>e<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">PrintWriter</span><span style="color: #009900;">&#40;</span>out<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/body&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/html&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


]]></content:encoded>
			<wfw:commentRss>https://www.berthou.com/us/2007/09/29/test-english/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
