<?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; exemple</title>
	<atom:link href="https://www.berthou.com/us/tag/exemple/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>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>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/><br />
This example can be used as a basis to do various things.</p>
<ul>
<li>Sending a file with a servlet<br/><br />
This involves two headers: Content-Type and Content-Disposition. The content type is set to &#8220;application/zip&#8221;. The other one is used to specify the filename used by the browser when it starts downloading the file.</p>
<pre class="alertCode">
res.setContentType("application/zip");
res.setHeader("Content-Disposition","inline; filename=output.zip;");
</pre>
<p>This header replace &#8220;res.setHeader(&#8220;Content-Disposition&#8221;,&#8221;attachment; filename=output.zip;&#8221;);&#8221; (not work with IE5)</p>
<p>In this example, we create a zip file. We&#8217;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.<br />
We simply call out.println(zip) to send the file.
</li>
<p>li>Creating a zip file Have you ever noticed the java.util.zip package ?<br/><br />
Basically, a zip file is created by adding ZipEntries to a ZipOutputStream.<br />
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.</p>
<pre class="alertCode">
zout.putNextEntry(new ZipEntry("file.html"));
zout.write(b,0,size);
zout.closeEntry();
zout.finish();
String zip=bout.toString();
</pre>
<p><span id="more-5"></span></p>

<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>
