<?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>NewInstance &#187; Web</title>
	<atom:link href="http://en.newinstance.it/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://en.newinstance.it</link>
	<description>A tech blog by Luigi R. Viggiano</description>
	<lastBuildDate>Tue, 07 Sep 2010 20:44:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Google Font API</title>
		<link>http://en.newinstance.it/2010/05/19/google-font-api/</link>
		<comments>http://en.newinstance.it/2010/05/19/google-font-api/#comments</comments>
		<pubDate>Wed, 19 May 2010 19:38:19 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Font]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2010/05/19/google-font-api/</guid>
		<description><![CDATA[Google just announced the Google Font API. This allows to include quality fonts in HTML pages, as easy as you were doing before with the "web-safe" fonts. You specify a css link, and the Google Font API will produce on the fly the CSS for your browser. Then you are ready to use any font [...]]]></description>
			<content:encoded><![CDATA[<p>Google just announced the <a href="http://code.google.com/apis/webfonts/">Google Font API</a>. This allows to include quality fonts in HTML pages, as easy as you were doing before with the "web-safe" fonts. </p>
<p>You specify a css link, and the Google Font API will produce on the fly the CSS for your browser. Then you are ready to use any font from the <a href="http://code.google.com/webfonts">Google Font Directory</a>, that currently is very little but it is easy to predict it will grow up very fast. Nevertheless, the few available Fonts looks pretty good!</p>
<p>Here an example:</p>
<pre class="brush: html">
&lt;link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'&gt;

&lt;div style="font-family: 'Lobster', arial, serif; font-size: xx-large; text-shadow: 4px 4px 4px rgb(170, 170, 170); text-align: center"&gt;
The quick brown fox jumps over the lazy dog.
&lt;/div&gt;
</pre>
<p>And here, what you get:</p>
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<div style="font-family: 'Lobster', arial, serif; font-size: x-large; text-shadow: 4px 4px 4px rgb(170, 170, 170); text-align: center">
The quick brown fox jumps over the lazy dog.
</div>
<p>Beautiful uh?</p>
<p>To make things even easier, the Google Font Directory also includes a <a href="http://code.google.com/webfonts/family?family=Lobster#code">code generator</a> that produces samples that can be grabbed and included in your HTML pages.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2006/02/01/font-size-problem-with-gnome-using-motif-applications/" rel="bookmark" class="crp_title">Font size problem with Gnome using Motif applications</a></li>
<li><a href="http://en.newinstance.it/2005/06/17/adding-hidden-fields-to-a-form/" rel="bookmark" class="crp_title">Adding hidden fields to a Form</a></li>
<li><a href="http://en.newinstance.it/2006/10/31/email-url-encoder-tool/" rel="bookmark" class="crp_title">Email URL Encoder Tool</a></li>
<li><a href="http://en.newinstance.it/2005/06/13/anti-spam-email-hiding-techniques/" rel="bookmark" class="crp_title">Anti spam email hiding techniques</a></li>
<li><a href="http://en.newinstance.it/2005/07/11/webwork-package-configuration-problem/" rel="bookmark" class="crp_title">Webwork Package Configuration Problem</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2010/05/19/google-font-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How GWT is useful in place of  Javascript and CSS?</title>
		<link>http://en.newinstance.it/2010/04/09/how-gwt-is-useful-in-place-of-javascript-and-css/</link>
		<comments>http://en.newinstance.it/2010/04/09/how-gwt-is-useful-in-place-of-javascript-and-css/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 10:54:24 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2010/04/09/how-gwt-is-useful-in-place-of-javascript-and-css/</guid>
		<description><![CDATA[Currently I am using GWT for a new project and I am really enthusiast of the results. I think it could be a nice article for this blog to explain some GWT ideas and how it is changing the way modern web application are being written. With GWT you use a subset of Java Core [...]]]></description>
			<content:encoded><![CDATA[<p>Currently I am using GWT for a new project and I am really enthusiast of the results. I think it could be a nice article for this blog to explain some GWT ideas and how it is changing the way modern web application are being written.</p>
<p>With GWT you use a subset of Java Core libraries and GWT apis to implement your web application. The web application later can be translated in a 100% JavaScript application that can invoke server side services also written in Java: plain servlets using GWT toolset that make easier to serialize and transfer object between the Java Server and JavaScript application you obtained from GWT. And, as everything is written in Java on the first step, it becomes very easy to keep structures compatible and aligned between client and server.</p>
<p>With GWT you can layout your html pages almost as usual, and inject your GWT components in DIVs defined in the hosting html page.<br />
Modeling the layout of forms and buttons and advanced controls is like writing Swing applications. But the interaction with the server must always be asyncronous (the first "A" of ajax).</p>
<p>GWT is cross browser (version 1.7 covers internet explorer 8 fanciness), has the best support for iternationalization I've ever seen in a web framework, can handle JSON, XML, SOAP or a native and simple google solution as protocol for calling remote services (GWT-RPC).</p>
<p>During the development you only debug Java code, in an "hosted mode" browser. You can put breakpoint on the code that later will be translated in JavaScript, and it really works fine.</p>
<p>If you have your javascript, you can write your Java "wrapper" and have that running as a native GWT library.</p>
<p>GWT also includes a good "back button" handling, javascript code obfuscation/optimization, and whatever you may dream to have from a framework.</p>
<p>but... it's not that simple! you will need some time to master all its feature and understand the internals.</p>
<p>Also a weakness is that at the moment you may have many troubles to get it working with maven, as GWT comes with a "standard" project layout relying on ant script. GWT provides a command line tool to jump start your project and have everything you need to import it in eclipse (maybe also intellij and netbeans).</p>
<p>GWT does not replace CSS. You still use CSS to modify how your GWT widgets will be rendered. Also there are some css predefined to have theming.</p>
<p>This is the <a href="http://code.google.com/intl/it/webtoolkit/gettingstarted.html">quickstart</a>.</p>
<p>This is the <a href="http://gwt.google.com/samples/Showcase/Showcase.html">showcase</a> to see some of the basic widget you can use and the java source code.</p>
<p>It may be surprising but the compilation from Java to JavaScript really works great! Recently a Java port of Quake (Jake) has been cross compiled into Javascript and HTML5 using GWT: <a href="http://code.google.com/p/quake2-gwt-port/">quake2-gwt-port</a>. </p>
<p>Source: <a href="http://www.linkedin.com/answers?viewQuestion=&#038;questionID=532985&#038;askerID=16203097&#038;goback=.mml_inbox_none_DATE_1.mid_1952559178">How GWT is useful in place of  Javascript and CSS?</a>
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2005/09/21/better-html-buttons-with-images/" rel="bookmark" class="crp_title">Better HTML Buttons&#8230; with images</a></li>
<li><a href="http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/" rel="bookmark" class="crp_title">Client-side HTML table pagination with JavaScript</a></li>
<li><a href="http://en.newinstance.it/2005/06/11/progress-bar-while-computing/" rel="bookmark" class="crp_title">Progress bar while computing&#8230;</a></li>
<li><a href="http://en.newinstance.it/2009/05/07/java-native-compilation/" rel="bookmark" class="crp_title">Java native compilation</a></li>
<li><a href="http://en.newinstance.it/2006/12/02/give-color-to-your-code/" rel="bookmark" class="crp_title">Give color to your code!</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2010/04/09/how-gwt-is-useful-in-place-of-javascript-and-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Tutorial: Ubuntu 9.04, Apache with SSL, Subversion over HTTP / HTTPs, and Trac</title>
		<link>http://en.newinstance.it/2009/08/27/tutorial-ubuntu-904-apache-with-ssl-subversion-over-http-https-and-trac/</link>
		<comments>http://en.newinstance.it/2009/08/27/tutorial-ubuntu-904-apache-with-ssl-subversion-over-http-https-and-trac/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 01:25:54 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2009/08/27/tutorial-ubuntu-904-apache-with-ssl-subversion-over-http-https-and-trac/</guid>
		<description><![CDATA[This tutorial will guide you through installation of Apache, HTTPS, Subversion and Trac, in order to have an (almost) complete development environment for your team. This article is divided in following steps 1. Installing Subversion 2. Installing Apache 3. Configuring Apache with SSL 4. Configuring Subversion with Apache (and SSL) 5. Installing Trac You may [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will guide you through installation of Apache, HTTPS, Subversion and Trac, in order to have an (almost) complete development environment for your team.</p>
<p>This article is divided in following steps </p>
<p>1. Installing Subversion<br />
2. Installing Apache<br />
3. Configuring Apache with SSL<br />
4. Configuring Subversion with Apache (and SSL)<br />
5. Installing Trac</p>
<p>You may choose for example to see how to install Apache and SSL, or having Apache plus subversion without Trac.<br />
Steps are voluntary isolated, and will require more operations than, for instance, issuing an &quot;apt-get install trac&quot; that will download and install all the packages in one step; but this will hopefully allow the readers to choose picking one section and forget about unneeded  components.<br />
I'll not explain what Subversion is, or what SSL is, etc. Ask google, for this info: I just say that for your software project you may need a server with those tools ready for your team.</p>
<h3>Requirements</h3>
<p> You need Ubuntu 9.04, in my case I used the &quot;server edition&quot; 64bit, while installing I used the minimal server mode pressing F4 to have a system as lighter as possible. But possibly this tutorial should be valid for Debian and previous Ubuntu version; but I have not verified that: if you do, post a comment to report your experience.</p>
<h3>Preparation</h3>
<p> After installing your server you have to ensure that apt system is up to date with available software on the repositories.  Type the following command:</p>
<pre>$ sudo apt-get update</pre>
<p>upgrading installed packages may be a good idea to do now:</p>
<pre>$ sudo apt-get upgrade</pre>
<p>Answer Yes if asked to download and install the upgrades.</p>
<h3>1. Installing Subversion</h3>
<p> From the command line type the command:</p>
<pre>$ sudo apt-get install subversion</pre>
<p>If everything went fine you should able to verify the Subversion version installed with following command:</p>
<pre>$ svn --version
svn, version 1.5.4 (r33841)
   compiled Aug  7 2009, 02:02:06

Copyright (C) 2000-2008 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme</pre>
<p>For now, let's stop here: how to create the Subversion repository, configure the users etc. Will be explained later in conjunction with Apache2 configuration. Maybe I'll write something on how to deal with svnserve, svnadmin, and user access control, in another article. </p>
<p>Later we will see how to create a repository, configure it with apache and HTTP basic authentication.</p>
<h3>2. Installing Apache</h3>
<p> To install apache 2 type the command:</p>
<pre>$ sudo apt-get install apache2</pre>
<p>When finished you should be able to connect with the browser at http://localhost and see the message &quot;It works!&quot;. Or you may verify that at the command line installing and using curl:</p>
<pre>$ sudo apt-get install curl
$ curl http://localhost
&lt;html&gt;&lt;body&gt;&lt;h1&gt;It works!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;</pre>
<h3>3. Configuring Apache with SSL</h3>
<p> Now we want to configure apache to run HTTPs.<br />
Following command will enable ssl Apache2 module with a2enmod (cryptic name for &quot;Apache2 enable module&quot;:</p>
<pre>$ sudo a2enmod ssl</pre>
<p>The previous command will suggest you to restart apache to let it to reload the configuration; ignore that message for now.</p>
<p>We need to enable the HTTPS port (443). Edit /etc/apache2/ports.conf and ensure that port 443 is defined as follows:</p>
<pre>$ sudo vi /etc/apache2/ports.conf</pre>
<pre># If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80

&lt;IfModule mod_ssl.c&gt;
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    NameVirtualHost *:443
    Listen 443
&lt;/IfModule&gt;</pre>
<p>I added the clause NameVirtualHost *:443 in the for SSL; this is not strictly necessary but it will be useful later if you want to have a VirtualHost for trac and other development services.</p>
<p>Now we need to configure the SSL site. Fortunately we have already the configuration file for that, we just need to enable it with a2ensite (cryptic name for &quot;apache2 enable site&quot;)</p>
<pre>$ sudo a2ensite default-ssl</pre>
<p>Again, the above command will suggest to reload apache configuration to activate the changes. This time the suggestion is almost right. As we made several changes I prefer to restart apache with following command:</p>
<pre>$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                                                              apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName</pre>
<p>If everything went fine you should see the above warning. You can ignore it, unless you want to configure the ServerName for your server. But this is out of scope, so do a search on Google, or consult an Apache expert.</p>
<p>So, if everything went fine, now we should be able to connect to our server through SSL.<br />
You can use firefox or curl, as before, but this time the URL will be https://localhost </p>
<pre>$ curl -k https://localhost
&lt;html&gt;&lt;body&gt;&lt;h1&gt;It works!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;</pre>
<p>the -k option is to ignore certification validation. Also firefox will complain that our certificate is invalid, but you can add it to exceptions and it will nomore bug you with those messages.</p>
<p>If everything went fine, now we should have Apache2, HTTP and HTTPs ready. </p>
<h3>4. Configuring Subversion with Apache (and SSL)</h3>
<p> First of all, we need to install the Subversion modules for Apache2.</p>
<pre>$ sudo apt-get install libapache2-svn</pre>
<p>They will be enabled by default. So you don't need to run a2enmod.</p>
<p>We only need to configure a repository. Let' say our project is called 'myproject'.</p>
<p>First of all, let's decide where our svn repositories will be created. I like /var/local/svn :</p>
<pre>$ sudo mkdir /var/local/svn</pre>
<p>Then let's create the repository using following procedure:</p>
<pre>$ sudo mkdir /var/local/svn/myproject
$ sudo chown www-data:www-data /var/local/svn/myproject
$ sudo -u www-data svnadmin create /var/local/svn/myproject</pre>
<p>Above commands will ensure that the user www-data (which is the apache user) can fully access the repository for reading and updating it.</p>
<p>We need to configure the repository in Apache. Edit /etc/apache2/mods-available/dav_svn.conf using:</p>
<pre>$ sudo vi /etc/apache2/mods-available/dav_svn.conf</pre>
<p>And add a section like the following one:</p>
<pre>&lt;Location /svn/myproject&gt;
  DAV svn
  SVNPath /var/local/svn/myproject
  AuthType Basic
  AuthName &quot;My Project Subversion Repository&quot;
  AuthUserFile /etc/subversion/myproject.passwd
  &lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt;
    Require valid-user
  &lt;/LimitExcept&gt;
&lt;/Location&gt;</pre>
<p>In the above file we indicated that, at the location svn our repository should respond. And for updating the repository we want a valid user. As per above configuration anonymous consultation is allowed; but you can disable it commenting with a leading '#' the lines &lt;LimitExcept ... and &lt;/LimitExcept&gt; or just removing them as in following example:</p>
<pre>&lt;Location /svn/myproject&gt;
  DAV svn
  SVNPath /var/local/svn/myproject
  AuthType Basic
  AuthName &quot;My Project Subversion Repository&quot;
  AuthUserFile /etc/subversion/myproject.passwd
  #&lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt;
    Require valid-user
  #&lt;/LimitExcept&gt;
&lt;/Location&gt;</pre>
<p>The above configuration indicates to Apache that even for consulting the repository we want a valid user.<br />
But valid users need a password, and in fact we indicated a password file for our repository called /etc/subversion/myproject.passwd. So let's create a password file with a couple of users:</p>
<pre>$ sudo htpasswd -c /etc/subversion/myproject.passwd luigi
$ sudo htpasswd /etc/subversion/myproject.passwd mario</pre>
<p>The -c option indicates that the password file should be created as new; and it is only necessary for the first user. Be aware of the fact that -c overwrites the existing password file without asking anything. Personally I think this is a quite stupid behavior, but that's the way it is.</p>
<p>Now we should be ready.</p>
<p>Let's reload apache configuration to make the changes effective:</p>
<pre>$ sudo /etc/init.d/apache2 reload</pre>
<p>and let's test with the browser that our svn repository is now accessible through HTTP and HTTPs at following urls:</p>
<p>http://localhost/svn/myproject/</p>
<p>https://localhost/svn/myproject/</p>
<p>We can also use curl to verify it is working:</p>
<pre>$ curl http://username:password@localhost/svn/myproject/
&lt;html&gt;&lt;head&gt;&lt;title&gt;myproject - Revision 0: /&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
 &lt;h2&gt;myproject - Revision 0: /&lt;/h2&gt;
 &lt;ul&gt;
 &lt;/ul&gt;
 &lt;hr noshade&gt;&lt;em&gt;Powered by &lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;Subversion&lt;/a&gt; version 1.5.4 (r33841).&lt;/em&gt;
&lt;/body&gt;&lt;/html&gt;</pre>
<pre>$ curl -k https://username:password@localhost/svn/myproject/
&lt;html&gt;&lt;head&gt;&lt;title&gt;myproject - Revision 0: /&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
 &lt;h2&gt;myproject - Revision 0: /&lt;/h2&gt;
 &lt;ul&gt;
 &lt;/ul&gt;
 &lt;hr noshade&gt;&lt;em&gt;Powered by &lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;Subversion&lt;/a&gt; version 1.5.4 (r33841).&lt;/em&gt;
&lt;/body&gt;&lt;/html&gt;</pre>
<p>Now we can also download our project using svn</p>
<pre>$ svn co https://localhost/svn/myproject myproject --username luigi</pre>
<p>"luigi" is obviously my username, substitute it with yours.<br />
The first time it will prompt for accepting the SSL certificate, answer to accept it permanently (p). Then it will optionally ask you for the password, type it.<br />
We can also test that modifying the remote repository is working with:</p>
<pre>$ svn mkdir -m &quot;created the trunk for the project&quot; https://localhost/svn/myproject/trunk --username luigi</pre>
<p>It will answer: Committed revision 1.  If so, we've done.</p>
<h3>5. Installing Trac</h3>
<p>To install trac files and required dependencies, type the following command:</p>
<pre>
$ sudo apt-get install trac
$ sudo apt-get install libapache2-mod-python
</pre>
<p>Let's create the directories for trac web folder:</p>
<pre>
$ sudo mkdir /var/local/trac
$ sudo chown www-data:www-data /var/local/trac
</pre>
<p>edit Apache configuration file for one of your enabled sites (in this example I modify the default http one, but you can choose to put trac on HTTPS modifying default-ssl) </p>
<pre>
$ sudo vi /etc/apache2/sites-enabled/000-default
</pre>
<p>and add the following lines at the end of the file, before the &lt;/VirtualHost&gt; tag:</p>
<pre>
        &lt;Location /projects&gt;
                SetHandler mod_python
                PythonInterpreter main_interpreter
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnvParentDir /var/local/trac
                PythonOption TracUriRoot /projects
                PythonOption PYTHON_EGG_CACHE /tmp
        &lt;/Location&gt;

        # use the following for one authorization for all projects
        # (names containing &quot;-&quot; are not detected):
        &lt;LocationMatch &quot;/projects/[[:alnum:]]+/login&quot;&gt;
            AuthType Basic
            AuthName &quot;trac&quot;
            AuthUserFile /etc/trac/trac.passwd
            Require valid-user
        &lt;/LocationMatch&gt;
</pre>
<p>Create a password file for trac users (if you want you can reuse or link the passwd file used for subversion  repositories)</p>
<pre>
$ sudo htpasswd -c /etc/trac/trac.passwd luigi
$ sudo htpasswd  /etc/trac/trac.passwd mario
... continue this way for all your users.
</pre>
<p>Create the trac environment for your project:</p>
<pre>
$ sudo -u www-data trac-admin /var/local/trac/myproject initenv
</pre>
<p>It will ask you some questions related to your project. Here's my answers in blue</p>
<pre>
Project Name [My Project]&gt; <span style="color:blue">My Project</span>
Database connection string [sqlite:db/trac.db]&gt; <span style="color:blue">[Just press Enter to accept the default]</span>
Repository type [svn]&gt;  <span style="color:blue">[Just press Enter to accept the default]</span>
Path to repository [/path/to/repos]&gt; <span style="color:blue">/var/local/svn/myproject</span>
</pre>
<p>Now let's restart apache:</p>
<pre>
$ sudo /etc/init.d/apache2 restart
</pre>
<p>Check that trac works properly connecting the browser to http://localhost/projects or use curl to verify that the url is responding properly as we did before. This url should display a link to &quot;My Project&quot;, click on it and you should see the project home page. Clicking on login the browser should ask you to provide username and password as recently defined with htpasswd command.</p>
<p>Last thing to do: add yourself as administrator for Trac. This will enable the Admin menu and allow to do much of the administration operations from the web, that you could also do at the command line with trac-admin tool.<br />
Execute the following command:</p>
<pre>
$ sudo -u www-data trac-admin /var/local/trac/myproject permission add luigi TRAC_ADMIN
</pre>
<p>This will make the username 'luigi' administrator for the project.</p>
<p>You can tune additional configuration settings in Trac to enable email notification, change the project logo, etc. Everything you need to know is on Trac <a href="http://trac.edgewall.org/wiki/TracGuide">website</a>. For the configuration check here: <a href="http://trac.edgewall.org/wiki/TracIni">http://trac.edgewall.org/wiki/TracIni</a></p>
<p>Hope everything went fine. Enjoy your development!
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2009/05/13/making-eclipse-javahl-working-recompiling-subversion-from-the-sources/" rel="bookmark" class="crp_title">Making Eclipse JavaHL working, recompiling Subversion from the sources</a></li>
<li><a href="http://en.newinstance.it/2010/08/03/maven-local-repository-modules/" rel="bookmark" class="crp_title">Maven Local Repository Modules</a></li>
<li><a href="http://en.newinstance.it/2008/07/02/disappointed-by-ganymede/" rel="bookmark" class="crp_title">Disappointed by Ganymede</a></li>
<li><a href="http://en.newinstance.it/2008/06/19/setting-up-javahl-jni-support-in-eclipse-on-linux/" rel="bookmark" class="crp_title">Setting up JavaHL (JNI) support in Eclipse on Linux</a></li>
<li><a href="http://en.newinstance.it/2009/05/20/svn-inconsistent-line-ending-style/" rel="bookmark" class="crp_title">svn: Inconsistent line ending style</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2009/08/27/tutorial-ubuntu-904-apache-with-ssl-subversion-over-http-https-and-trac/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>JSPs cannot be packaged as components</title>
		<link>http://en.newinstance.it/2008/06/30/jsps-cannot-be-packaged-as-components/</link>
		<comments>http://en.newinstance.it/2008/06/30/jsps-cannot-be-packaged-as-components/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 21:28:30 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2008/06/30/jsps-cannot-be-packaged-as-components/</guid>
		<description><![CDATA[Last time I used .ear packaging there was no support for sharing information between web applications: you needed to use web services, rest, etc. This evening I just made a search on the internet to check if things are better now. It seems that nothing is changed. I found that some application servers have implemented [...]]]></description>
			<content:encoded><![CDATA[<p>Last time I used .ear packaging there was no support for sharing information between web applications: you needed to use web services, rest, etc. This evening I just made a search on the internet to check if things are better now. It seems that nothing is changed.<br />
I found that some application servers have implemented proprietary solutions, to <a href="http://http://dev2dev.bea.com/blog/prash007/archive/2005/09/sharing_session.html">share the session between web applications</a>. I suppose that the environments for the web applications are isolated and you probably still need to juggle with the packaging.</p>
<p>Some years ago, I and one of my friends were developing a product that was having common features for different customers. We was trying to find a way to keep a single application under development, having separated modules for the customizations. It was impossible with the current J2EE specification and we had to play a lot with CVS and Ant scripts. Finally we ended splitting the application in different branches.<br />
Today, I am planning a web application and I would like to use maven to package features inside a web applications as plugins. </p>
<p>It would be nice if Java web application specification were supporting a structure of  a superwar containing subwars into the WEB-INF/lib in addition of the jar files that we already have. A sort of web application that can be deployed inside other ones. A web application component (wac?). For instance, I could write a web application component to handle the registration, the login, and the user management, and deploy that feature in all the applications needing that.</p>
<p>If JSP were able to be loaded from the ClassPath, like a velocity template, it would have been a great solution as well: you can package all the web resources needed for one feature into a .jar artifact to be included in the web archive as a normal library inside WEB-INF/lib. Imagine if your web application can be split in jar files implementing set of features that you can sell separately: the core war file at runtime could just check for the presence of the available features, detecting implementing class in the ClassPath, and enable new menu items and widgets. Also the customer could cut off features that he doesn't want, simplifying the user interface, and lighten the deployment and the memory footprint.</p>
<p>Template engines, like Velocity or FreeMarker, can fit this: templates are loaded as stream from any source. JSPs can not. Unless you intend to pre-compile them and export in the containing war all the mappings for the generated Servlets. Not really convenient.<br />
This limitation is a real pity: over the years JSP has become much powerful but this limitation drastically cuts the field of applicability for this technology if your goal is the reuse. I read some company blogs that was implementing special mechanisms to support component deployment and <a href="http://blog.linkedin.com/blog/2008/06/osgi-at-linke-1.html">JSP loading from the ClassPath</a>:</p>
<blockquote><p>
JSP files can be located anywhere: inside the war, on the file system, inside a local jar file, inside a remote jar file or a combination of all those. This is quite nice in development because JSPs can be located in the source tree (instead of packaged in a WAR) and developers can be much more productive.
</p></blockquote>
<p>This feature needs to be included in the standard JSP specification.<br />
I did some research on the past to see if it was possible, using a ServletFilter, to substitute the ServletContext with an extended one having the ability to load JSP files from the CassPath. At that time, this attempt was not successful; I'll try again, to see if in the meantime Tomcat or Jetty added this possibility out of the box, or if this time my playing with the Servlet Container will be more lucky.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2008/07/07/self-executing-war-files/" rel="bookmark" class="crp_title">Self executing war files</a></li>
<li><a href="http://en.newinstance.it/2006/11/03/excel-file-generation-made-easyer/" rel="bookmark" class="crp_title">Excel file generation made easy(er)</a></li>
<li><a href="http://en.newinstance.it/2005/09/21/better-html-buttons-with-images/" rel="bookmark" class="crp_title">Better HTML Buttons&#8230; with images</a></li>
<li><a href="http://en.newinstance.it/2010/04/21/uninstalling-pkg-files-on-osx/" rel="bookmark" class="crp_title">Uninstalling .pkg files on OSX</a></li>
<li><a href="http://en.newinstance.it/2008/06/21/displaying-version-in-a-maven-based-project/" rel="bookmark" class="crp_title">Displaying the version in a Maven-based project</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2008/06/30/jsps-cannot-be-packaged-as-components/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The passwords hell</title>
		<link>http://en.newinstance.it/2008/06/27/the-passwords-hell/</link>
		<comments>http://en.newinstance.it/2008/06/27/the-passwords-hell/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 18:03:48 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2008/06/27/the-passwords-hell/</guid>
		<description><![CDATA[Registration/Login is the #1 usability problem on websites. I hate security paranoia when it is not needed (ok, I can understand a bank&#8230;) My suggestions to avoid boring the people using our software: Let the user choose the preferred password. Don&#8217;t assign it your own (especially with random chars!!!). User will forget it and abandon [...]]]></description>
			<content:encoded><![CDATA[<p>Registration/Login is the #1 usability problem on websites.<br />
I hate security paranoia when it is not needed (ok, I can understand a bank&#8230;)</p>
<p>My suggestions to avoid boring the people using our software:</p>
<ol>
<li> Let the user choose the preferred password. Don&#8217;t assign it your own (especially with random chars!!!). User will forget it and abandon the damn website. If your ego wants you to write a very cool password generator, provide it as an option in alternative to pick their own, for the eternal undecided. Mailing the password (choosen by you) is boring enough to let the user go away, at least the time to check the email&#8230; and it may be too late.</li>
<li> Don&#8217;t require the user to change the password on first login.</li>
<li> Implement a good and safe &#8220;remember me&#8221; feature. </li>
<li> Don&#8217;t impose restriction rules on user passwords: don&#8217;t ask for special chars, don&#8217;t require a minimum lenght, don&#8217;t mandate periodical password changes, don&#8217;t memorize the password history to prevent password repetitions. User will use password like &#8220;a1111111$&#8221; and periodically change it to &#8220;a2222222$&#8221;, or attach a post-it on the monitor,  just to be able to remind it: you think that is more secure? Just warn that short password=low security, or provide a measure to tell the user how strong is his chosen password.</li>
<li> When the user writes wrong user name or password, don&#8217;t say &#8220;the password is wrong&#8221; and &#8220;username not registered&#8221; or more idiocy: implement a mastermind if you like video games leaving your job to a smart guy, and don&#8217;t help crackers to guess.</li>
<li> Don&#8217;t lock the account when the user is logged in. This is also known as &#8220;single session per user&#8221;. It&#8217; just insanity.</li>
<li> Don&#8217;t require the user to remember the email with which he subscribed. Allow the user to retrieve the password by user name, email address, or just his name, and send it by mail. Remember the CAPTCHA, to avoid mailbox flooding.</li>
<li>The &#8220;secret question&#8221; test to permit the user to recover a &#8220;lost password&#8221; situation is good option, but may be risky because the answer can be guessed: use smart questions. Example: not the birth date that could be on user skype profile; nor the car number plate that is publicly visible. Allow the user to write his secret question. You can allow the user to access the website and change the password without using emails (sometime people changes/abandon mailboxes): when the user correctly responds to a &#8220;secret question&#8221; test, don&#8217;t send him any email: let him log in without the password, and give him the chance to change it.</li>
<li>Don&#8217;t require the user to register. If possible, offer a &#8220;guest experience&#8221;, and suggest the user to subscribe only when he feels it worths the pain or if your application need to store information specific to the user. An option could be to create a temporary guest account when a new user visit the site, warning the user that guest accounts are periodically cleaned up and he risks to loose the work done. On cleaning up, remove before the guests that don&#8217;t login after much time and keep the others.</li>
<li>To protect against password guessers I would lock the account after a certain number (enough high) of tries. When the lock happens automatically send the mail to the account owner with the &#8220;password reset link&#8221; and the &#8220;user unlock&#8221; link. This feature may be configurable: user may not like this.</li>
<li>Displaying the &#8220;last login&#8221; information to the user can help the user to detect if someone not authorized is using his account.</li>
</ol>
<p>Of course those suggestions are not valid for websites that require a strong security, but they can provide enough security for 99% of the site we daily use.<br />
Let the users be responsible of their security, and if they choose a stupid password, worse for them! Against stupidity the gods themselves struggle in vain.</p>
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2008/07/17/secure-storage-in-ganymede-is-forced-paranoia/" rel="bookmark" class="crp_title">&#8220;Secure Storage&#8221; in Ganymede is forced paranoia</a></li>
<li><a href="http://en.newinstance.it/2005/07/28/bug-parade/" rel="bookmark" class="crp_title">Bug Parade</a></li>
<li><a href="http://en.newinstance.it/2008/04/01/remote-desktop-and-the-black-screen/" rel="bookmark" class="crp_title">Remote Desktop and the Black Screen</a></li>
<li><a href="http://en.newinstance.it/2005/09/02/improving-security-on-openssh/" rel="bookmark" class="crp_title">Improving security on OpenSSH</a></li>
<li><a href="http://en.newinstance.it/2009/11/26/karmic-and-luks-usb-drive-encryption-made-almost-easy/" rel="bookmark" class="crp_title">Karmic and Luks: USB drive encryption made (almost) easy</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2008/06/27/the-passwords-hell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>One request, multiple requests. When failover makes your application fail&#8230;</title>
		<link>http://en.newinstance.it/2007/09/03/one-requests-multiple-requests-when-failover-makes-your-application-fail/</link>
		<comments>http://en.newinstance.it/2007/09/03/one-requests-multiple-requests-when-failover-makes-your-application-fail/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 13:46:06 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2007/09/03/one-requests-multiple-requests-when-failover-makes-your-application-fail/</guid>
		<description><![CDATA[This is a story about a problem that can happen if your web application has operations that will require a long time (let&#8217;s say more than 30 seconds) to generate a response for the browser. Figuring out what is happening, could not always be so easy. Especially if you didn&#8217;t wrote the application and the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a story about a problem that can happen if your web application has operations that will require a long time (let&#8217;s say more than 30 seconds) to generate a response for the browser. </p>
<p>Figuring out what is happening, could not always be so easy. Especially if you didn&#8217;t wrote the application and the logging system does not help you.  Here&#8217;s my story.</p>
<p><strong>The symptoms.</strong><br />
Some days ago I&#8217;ve been entrusted to solve a problem on an application deployment. The problem was that, during an operation involving a complex database transaction during several minutes, the application was crashing giving an Oracle exception in the logs: <em>ORA-00054: resource busy and acquire with NOWAIT specified</em>.<br />
The problem was given only on a specific deployment, while in many other environments the operations was completing successfully.</p>
<p>Initially I thought there were some external process that was locking the table (like, some user with an open TOAD on the table), but with the help of a DBA, we removed all the locks and we ran the process while nobody else was connected. Monitoring the database while running, we found more strange things: there were more connections open doing stuff on the database.<br />
Also from the application log (very very verbose) we found that the operations were made in wrong order. The thread number was not included in the log, so I was thinking about wrong order of operations in the code. And this was scary because I was unable to understand how this could possibly work in other environments.<br />
After a careful code review, I concluded that the code was doing the operations in the correct order. Code don&#8217;t lie, even when it&#8217;s bad code.<br />
Looking at the logs, I noticed a strange things: similar log lines were repeated at distance of almost exactly 30 seconds.<br />
Summarizing, I needed an hypothesis that explains all the following weirdness:</p>
<ul>
<li>Problem was happening only on a specific deployment, while not happening in other environments.</li>
<li>The code was implementing database operations in the right order, but from the log I was getting things executed in a different order.</li>
<li>The number of database connections for that transaction was higher (3x) than the number I was expecting to be. </li>
<li>Looking carefully at the logs, there were similar messages distanced almost exactly by 30 seconds. </li>
<li>Locks on database resources that should not occur.</li>
</ul>
<p><strong>The solution of the mystery</strong><br />
What actually is happening is that the <em>browser sends a single request, but the application server receives many requests</em>. The application was not checking that the operation was already running, so many requests started many operations that was requiring exclusive locks on the database, causing the application fail with that error. </p>
<p>But, how is it possible that a single browser request can result in many requests on the server? I supposed that there were an intermediary server that was doing that. And there were: Apache. </p>
<p>This is what it was happening:</p>
<ol>
<li>The user&#8217;s browser sends the request for the operation.</li>
<li>Apache receives the request and forwards the same request to the application server.</li>
<li>Apache waits for the application server to respond.</li>
<li>After 30 seconds Apache doesn&#8217;t get the response from the application server, so Apache thinks that the application server has not received the request or that the server has gone down.</li>
<li>Some fail-over mechanism implemented in Apache makes it to reissue the request to the application server. So in the log messages you can guess that a second request is received, after almost exactly 30 seconds.</li>
<li>steps 4 and 5 repeats again, so a third request thread start on the application server.</li>
<li>Those parallel threads then make the application server to try to lock database resources that were already locked by previous requests.</li>
<li>After the 3rd request goes in timeout the Apache decides that no applications server are alive to respond, and returns an error to the browser.</li>
<li>The browser display the error returned by Apache, but the application server still continue to run the started threads, of course failing.</li>
</ol>
<p>So, the solution can be, to remove the Apache server in the middle that is causing this behavior, or reconfigure it to have a longer timeout to allow the first thread to complete, or disabling this behavior at all.</p>
<p>Also, the application should not allow multiple threads to run exclusive locking operations. It should implement a sort of synchronization to give the user an error message saying that the operation is already running and cannot be started again until it is finished. But this does not solve the timeout problem on the middle server, as also the first user could get the warning message.</p>
<p>I noticed previously that also <a href="http://edocs.bea.com/wls/docs70/plugins/apache.html#113659">Weblogic module for Apache implements a similar fail-over mechanism</a>. So, be aware of that, and consider the case.</p>
<p>Now, it just remains to convince the deployment guys that we are not responsible of what they put between the application and the browser.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2009/04/02/more-on-tracing-network-connections/" rel="bookmark" class="crp_title">More on tracing network connections.</a></li>
<li><a href="http://en.newinstance.it/2005/06/17/my-new-net-server/" rel="bookmark" class="crp_title">My New Net Server</a></li>
<li><a href="http://en.newinstance.it/2006/11/03/excel-file-generation-made-easyer/" rel="bookmark" class="crp_title">Excel file generation made easy(er)</a></li>
<li><a href="http://en.newinstance.it/2008/10/17/concurrent-locking-for-dummies/" rel="bookmark" class="crp_title">Concurrent locking for dummies</a></li>
<li><a href="http://en.newinstance.it/2005/07/28/bug-parade/" rel="bookmark" class="crp_title">Bug Parade</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2007/09/03/one-requests-multiple-requests-when-failover-makes-your-application-fail/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Free speech? Not in Italy: Piero Ricca&#8217;s Blog censored.</title>
		<link>http://en.newinstance.it/2007/07/11/free-speech-not-in-italy-piero-riccas-blog-censored/</link>
		<comments>http://en.newinstance.it/2007/07/11/free-speech-not-in-italy-piero-riccas-blog-censored/#comments</comments>
		<pubDate>Wed, 11 Jul 2007 09:16:44 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Life, universe and everything]]></category>
		<category><![CDATA[Opinions]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2007/07/11/free-speech-not-in-italy-piero-riccas-blog-censored/</guid>
		<description><![CDATA[Piero Ricca, is an Italian citizen owning a blog in which he speaks about politics and justice. A sort of Italian Michael Moore, I would say. Yesterday, the blog of my friend Piero Ricca has been censored. Blocked actually, as Italian police has changed passwords, blocked posts and comments on that site, deleted articles. You [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.alkemik.com/alkemik/pieroricca.jpg" /></p>
<p>Piero Ricca, is an Italian citizen owning a blog in which he speaks about politics and justice. A sort of Italian Michael Moore, I would say.</p>
<p>Yesterday, the <a href="http://www.pieroricca.org">blog of my friend Piero Ricca</a> has been censored. Blocked actually, as Italian police has changed passwords, blocked posts and comments on that site, deleted articles.</p>
<p>You can see automated translation of the deleted articles, from google cache: <a href="http://www.google.com/translate?u=http%3A%2F%2F64.233.183.104%2Fsearch%3Fq%3Dcache%3Awc911Myjjw8J%3Awww.pieroricca.org%2F2007%2F04%2F17%2Femilio-fede%2F%2Bsite%3Apieroricca.org%2Bfede%26hl%3Dit%26ct%3Dclnk%26cd%3D2%26gl%3Dit%26amp&#038;langpair=it%7Cen&#038;hl=en&#038;ie=UTF8">Emilio Fede</a>; <a href="http://www.google.com/translate?u=http%3A%2F%2F64.233.183.104%2Fsearch%3Fq%3Dcache%3Aqt6KA5pOpBQJ%3Awww.pieroricca.org%2F2007%2F04%2F28%2Femilio-fede-2lo-sputo%2F%2Bsite%3Apieroricca.org%2Bfede%26hl%3Dit%26ct%3Dclnk%26cd%3D1%26gl%3Dit%26amp&#038;langpair=it%7Cen&#038;hl=en&#038;ie=UTF8">Emilio Fede: the spit</a>. Original italian version here: <a href="http://64.233.183.104/search?q=cache:wc911Myjjw8J:www.pieroricca.org/2007/04/17/emilio-fede/+site:pieroricca.org+fede&amp;hl=it&amp;ct=clnk&amp;cd=2&amp;gl=it&amp;amp" target="_blank">Emilio Fede</a>, <a href="http://64.233.183.104/search?q=cache:qt6KA5pOpBQJ:www.pieroricca.org/2007/04/28/emilio-fede-2lo-sputo/+site:pieroricca.org+fede&amp;hl=it&amp;ct=clnk&amp;cd=1&amp;gl=it&amp;amp" target="_blank">Emilio Fede: lo sputo</a></p>
<p>What happened? Why this blog has been banned? I explain it briefly.</p>
<p>Some days ago, Piero met Emilio Fede, a &#8220;journalist&#8221;, director of TG4, of Rete4 (Berlusconi&#8217;s TV network) and asked him about how it is possible that Rete4 continues to transmit using abusive TV frequencies: there&#8217;s a sentence of the Constitutional Court that was assigning those frequencies to &#8220;Europa 7&#8243;, but Rete4 continues to transmit despite the law.<br />
In response to that question Piero received insults and a spittle, and when Piero answered to the journalist, he got intimidating menaces and also law actions menaces.<br />
There&#8217;s a video on youtube of the episode: <a href="http://www.youtube.com/watch?v=5KbGNQwO7es">Piero Ricca vs Emilio Fede</a>.</p>
<p>Yesterday, his blog has been preventatively seized.</p>
<p>So a pirate TV owned by the ex-prime minister Silvio Berlusconi, can continue to work for years, but if a citizen asks for explanations gets banned from internet. Usual stuff for Italian Justice: strong with common citizen, weak with potents.</p>
<p>Here, the post from beppegrillo.it: <a href="http://www.beppegrillo.it/eng/2007/07/v_as_in_emilio_fede.html">V as in Emilio Fede</a>.</p>
<p><a href="http://www.technorati.com/blogs/pieroricca.org?reactions">Every blog in Italy is echoing the news</a>. </p>
<p>The message from Piero Ricca in the comments of his last blog post:</p>
<blockquote><p>
I am Piero Ricca.</p>
<p>DEAR FRIENDS, I CANNOT UPDATE THE BLOG. It has been closed by an act of the Rome Prosecutors’ office, a “preventative removal” that I was notified of at 2:00pm today by two officers of the Finance Police of the “special unit against ICT frauds” who came from Rome. The action has happened as a result of an action for defamation presented by Emilio Fede against myself for the famous confrontation at the Press Circle. With the same measure they have deleted one of my posts relating to the Fede affair and the related comments. For technical reasons, they have not been able to remove the video from YouTube.<br />
Naturally I will immediately ask for the reversal of the action. In the meantime I can just write these lines here. In a short while, I will send a communication to the sites of friends, and I’m asking you now to distribute it.<br />
With Fede there’ll be an encounter in the tribunal, perhaps even in front of one of the magistrates who has been defamed and spied upon during the years of the government of his employer.<br />
And we will continue to criticise him and those like him in public places, in new displays of dissent.<br />
No one will manage to remove the freedom of expression from me and from the friends of Qui Milano Libera and of the blog: this is certain.<br />
Thanks to all.” </p>
<p>Piero Ricca
</p></blockquote>
<p>Now Piero is evaluating to move his blog outside Italy, to avoid censor for the future. It seems that the website <a href="http://www.quimilanolibera.net/">Qui Milano Libera</a> will host Piero&#8217;s voice while his blog is under block.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2007/02/05/interview-on-java-journal/" rel="bookmark" class="crp_title">Interview on Java Journal</a></li>
<li><a href="http://en.newinstance.it/2008/12/03/false-alarm-actnsswift-virus-in-embedded-youtube-videos/" rel="bookmark" class="crp_title">False alarm: Actns/Swif.T Virus in embedded Youtube videos?</a></li>
<li><a href="http://en.newinstance.it/2008/11/14/italian-politicians-against-bloggers-again/" rel="bookmark" class="crp_title">Italian politicians against bloggers, again&#8230;</a></li>
<li><a href="http://en.newinstance.it/2005/06/16/joel-on-software-book/" rel="bookmark" class="crp_title">Joel on Software Book</a></li>
<li><a href="http://en.newinstance.it/2007/06/29/oracle-driver-bug-with-jdk-15/" rel="bookmark" class="crp_title">Oracle thin JDBC driver bug with JDK 1.5</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2007/07/11/free-speech-not-in-italy-piero-riccas-blog-censored/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JRainbow, the (unknown) online source code colorer, now supports XML</title>
		<link>http://en.newinstance.it/2007/06/15/jrainbow-the-unknown-online-source-code-colorer-now-supports-xml/</link>
		<comments>http://en.newinstance.it/2007/06/15/jrainbow-the-unknown-online-source-code-colorer-now-supports-xml/#comments</comments>
		<pubDate>Fri, 15 Jun 2007 13:38:19 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2007/06/15/jrainbow-the-unknown-online-source-code-colorer-now-supports-xml/</guid>
		<description><![CDATA[I&#8217;ve made some refactoring to make JRainbow support several languages. The result is that now JRainbow supports XML coloring. To learn more about JRainbow source code colorer, check the JRainbow Project Website. Here you can try it right now: XML sintax coloring is almost complete, just need some improvement to support inline DTDs. Related Posts: [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made some refactoring to make JRainbow support several languages. The result is that now JRainbow supports XML coloring. </p>
<p>To learn more about JRainbow source code colorer, check the <a href="http://jrainbow.newinstance.it/">JRainbow Project Website</a>.</p>
<p>Here you can try it right now:</p>
<p><iframe height="430" width="500" scrolling="no" src="http://newinstance.s42.eatj.com/jrainbow/"  frameborder="0"></iframe><br />
XML sintax coloring is almost complete, just need some improvement to support inline DTDs.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2006/12/02/give-color-to-your-code/" rel="bookmark" class="crp_title">Give color to your code!</a></li>
<li><a href="http://en.newinstance.it/2007/08/24/building/" rel="bookmark" class="crp_title">Building&#8230;</a></li>
<li><a href="http://en.newinstance.it/2006/06/24/gtalk-jabber-and-other-im-protocols/" rel="bookmark" class="crp_title">GTalk, Jabber and other IM protocols</a></li>
<li><a href="http://en.newinstance.it/2006/07/08/javaday06-torino-photoreport/" rel="bookmark" class="crp_title">JavaDay&#8217;06 @Torino, Photoreport</a></li>
<li><a href="http://en.newinstance.it/2005/09/21/better-html-buttons-with-images/" rel="bookmark" class="crp_title">Better HTML Buttons&#8230; with images</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2007/06/15/jrainbow-the-unknown-online-source-code-colorer-now-supports-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ORA-12519, TNS:no appropriate service handler found</title>
		<link>http://en.newinstance.it/2007/06/01/ora-12519-tnsno-appropriate-service-handler-found/</link>
		<comments>http://en.newinstance.it/2007/06/01/ora-12519-tnsno-appropriate-service-handler-found/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 11:26:59 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2007/06/01/ora-12519-tnsno-appropriate-service-handler-found/</guid>
		<description><![CDATA[I used to hate Oracle Database (and other Oracle products too) because of it is much more complicated / heavyweight / slow / buggy and full of useless and sometime harmful stuff than needed. Also when you install you can&#8217;t remove it without leaving tons of zombie files around, breaking your JVM/Apache/Windows/etc. After an Oracle [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://img507.imageshack.us/img507/8691/oracleac1.jpg" alt="Oracle buildings... " /></p>
<p>I used to hate Oracle Database (and other Oracle products too) because of it is much more complicated / heavyweight / slow / buggy and  full of useless and sometime harmful stuff than needed. Also when you install you can&#8217;t remove it without leaving tons of zombie files around, breaking your JVM/Apache/Windows/etc. After an Oracle installation, your system will never be as before. And hey, have you ever seen an &#8220;universal installer&#8221; more pathetic than the oracle one? </p>
<p>But I see they are finally realizing that, so they released a <a href="http://www.oracle.com/technology/products/database/xe/pdf/dbxe_datasheet.pdf">&#8220;no-frills edition&#8221;</a> of their database (160MB sized download, 700MB of memory used on my laptop, 1.2GB of disk space. &#8220;no frills&#8221;? wow! I&#8217;ll try to install it on my cellphone) that can be freely used for development and production. With native installer (happy to see that installer in the garbage)</p>
<p>The <em>good</em> news is that <em>&#8220;Oracle Database XE is created from the same code base as the Oracle Database 10g product line&#8221;</em>, so that you still have &#8211; for free! &#8211; the same usual Oracle buggy stuff (<a href="http://www.google.it/search?q=varchar2+vs+varchar">&#8220;varchar 2, the revenge!&#8221;</a>, <a href="http://www.google.com/search?q=empty+string+oracle">empty string == null</a>, <a href="http://www.google.it/search?hl=it&#038;rlz=1B3GGGL_enDE216DE217&#038;q=blob+clob+4k+oracle&#038;btnG=Cerca&#038;meta=">blob/clob limitation to 4k</a>, etc), bugs, and nice useless error messages like</p>
<ul>
<li> &#8220;ORA-00020: Maximum number of processes (%s) exceeded&#8221; (notice the %s)</li>
<li> &#8220;ORA-00904: invalid column name&#8221; (now guess which one!)</li>
<li> &#8220;ORA-00942: table or view does not exist&#8221; (when you join 96 tables in a query)</li>
<li> &#8220;ORA-00911: invalid character&#8221; (when your query is 1 billion character long&#8230;)</li>
<li> &#8220;ORA-01722: invalid number&#8221; (maybe I typed slevin?)</li>
<li> &#8230;and much more!</li>
</ul>
<p>But now you have additional bugs due to the &#8220;no-frills edition&#8221;. </p>
<p>For example this one: when you use your poor Oracle connected application, after some time of activity you get &#8220;ORA-12519, TNS:no appropriate service handler found&#8221;, and you don&#8217;t get any more connection from the db, with SQLExceptions instead. The <em>quick</em> way to solve, is to restart the listener. Not bad uh, for a &#8220;proven industry database&#8221;, isn&#8217;t that?</p>
<p>Googling around <a href="http://forums.oracle.com/forums/thread.jspa?messageID=1255542">I found</a> that this is a bug on how OracleXE monitors processes, and issuing the following command at SQL command line will fix it (after restarting the listener): &#8220;ALTER SYSTEM SET PROCESSES=150 SCOPE=SPFILE;&#8221;.<br />
Worked for me. This saved me to install Oracle Enterprise on my laptop.</p>
<p>So, let&#8217;s run to download this new gem from Oracle and have fun!
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2007/06/29/oracle-driver-bug-with-jdk-15/" rel="bookmark" class="crp_title">Oracle thin JDBC driver bug with JDK 1.5</a></li>
<li><a href="http://en.newinstance.it/2007/07/05/oracle-workarounds-use-jdk-14/" rel="bookmark" class="crp_title">Oracle workarounds: use JDK 1.4</a></li>
<li><a href="http://en.newinstance.it/2008/06/23/very-quick-linux-tips/" rel="bookmark" class="crp_title">Very Quick Linux Tips</a></li>
<li><a href="http://en.newinstance.it/2010/08/31/lady-java/" rel="bookmark" class="crp_title">Lady Java</a></li>
<li><a href="http://en.newinstance.it/2005/07/11/hibernate-and-database-views/" rel="bookmark" class="crp_title">Hibernate and Database Views</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2007/06/01/ora-12519-tnsno-appropriate-service-handler-found/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>MSWord generation made easy(er)</title>
		<link>http://en.newinstance.it/2007/03/23/msword-generation-made-easyer/</link>
		<comments>http://en.newinstance.it/2007/03/23/msword-generation-made-easyer/#comments</comments>
		<pubDate>Fri, 23 Mar 2007 15:30:48 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://it.newinstance.it/2007/03/23/msword-generation-made-easyer/</guid>
		<description><![CDATA[In my swing application the requirement was that the user had to be able to issue an action, from a menu or from a button, that generates a letter from a defined msword template filled with data load from the database. Then the application should launch msword to make a preview that the user can [...]]]></description>
			<content:encoded><![CDATA[<p>In my swing application the requirement was that the user had to be able to issue an action, from a menu or from a button, that generates a letter from a defined msword template filled with data load from the database. Then the application should launch msword to make a preview that the user can manually complete or edit, then save or print.</p>
<p>But, Microsoft Word file format is not public, and generating such kind of file from Java is not that easy. There are libraries, like <a href="http://jakarta.apache.org/poi/">jakarta POI</a>, but they are quite complex, and limited; and generating a print layout using those Java API could become a nightmare.<br />
The solution, as for the <a href="http://it.newinstance.it/2006/11/03/excel-file-generation-made-easyer/">excel example</a>, is to create a textual format from a word document, that can be easily manipulated: <a href="http://it.wikipedia.org/wiki/Rich_Text_Format">RTF</a>.<br />
RTF, as msword, supports textfields that can be referenced by bookmarks and can be filled modifying the content of the file.</p>
<p>I got the templates, then I added textfield associating them to a bookmark:<br />
<a href="http://it.newinstance.it/wp-content/uploads/2007/03/msword-textfield.jpg" target="_blank"><br />
<img id="image228" src="http://it.newinstance.it/wp-content/uploads/2007/03/msword-textfield.jpg" alt="MSWord Textfields" height="390" width="475"/></a><br />
<em>Example of a template with textfields. Click to maximize</em></p>
<p>For example, the rtf source code for the &#8220;name&#8221; bookmark in above image, will look like:</p>
<pre style="height: 60px;">
{\\field{\\*\\fldinst {\\lang2057\\langfe1040\\langnp2057 {\\*\\<strong>bkmkstart name</strong>} FORMTEXT }{\\lang2057\\langfe1040\\langnp2057 {\\*\\datafield 0000000000000000046e616d6500000000000000000000000000
}{\\*\\formfield{\\fftype0\\fftypetxt0{\\*\\ffname name}}}}}{\\<strong>fldrslt</strong> {\\lang1024\\langfe1024\\noproof\\langnp2057 <span style="background: yellow">\\u8194\\'20\\u8194\\'20\\u8194\\'20\\u8194\\'20\\u8194\\'20</span>}}}{\\lang2057\\langfe1040\\langnp2057 {\\*\\<strong>bkmkend name</strong>}
</pre>
<p>I agree, not that easy to understand. The thing is that, if you modify the <span style="background: yellow">highlited text</span> you get the field filled with your value. In bold the keywords I used in my code to locate the position of the text to replace.<br />
So, it becomes just a matter of searching the template file for field values identified by the bookmark, and replacing it with the desired value. </p>
<p>Here&#8217;s a simplified version of the class that does this job:</p>
<pre class="java" style="max-height: 300px; height: 300px;"><span class="line_number"> 1</span><span class="code"><span class="java_keyword">package</span> it.newinstance.util.rtf;
<span class="line_number"> 2</span>
<span class="line_number"> 3</span><span class="java_keyword">import</span> java.io.FileOutputStream;
<span class="line_number"> 4</span><span class="java_keyword">import</span> java.io.IOException;
<span class="line_number"> 5</span><span class="java_keyword">import</span> java.io.InputStream;
<span class="line_number"> 6</span>
<span class="line_number"> 7</span><span class="java_keyword">public</span> <span class="java_keyword">class</span> RTF <span class="parenthesis">{</span>
<span class="line_number"> 8</span>    <span class="java_keyword">private</span> StringBuilder builder;
<span class="line_number"> 9</span>
<span class="line_number">10</span>    <span class="java_keyword">public</span> RTF<span class="parenthesis">(</span>InputStream in<span class="parenthesis">)</span> <span class="java_keyword">throws</span> IOException <span class="parenthesis">{</span>
<span class="line_number">11</span>        builder = <span class="java_keyword">new</span> StringBuilder<span class="parenthesis">(</span><span class="numeric_constant">16384</span>);
<span class="line_number">12</span>        <span class="java_primitive_type">int</span> ch;
<span class="line_number">13</span>        <span class="java_keyword">while</span> <span class="parenthesis">((</span>ch = in.read<span class="parenthesis">())</span> != -<span class="numeric_constant">1</span>)
<span class="line_number">14</span>            builder.append<span class="parenthesis">((</span><span class="java_primitive_type">char</span><span class="parenthesis">)</span> ch<span class="parenthesis">)</span>;
<span class="line_number">15</span>    <span class="parenthesis">}</span>
<span class="line_number">16</span>
<span class="line_number">17</span>    <span class="java_keyword">public</span> <span class="java_primitive_type">boolean</span> set<span class="parenthesis">(</span>String fieldName, String fieldValue<span class="parenthesis">)</span> <span class="parenthesis">{</span>
<span class="line_number">18</span>        <span class="java_primitive_type">int</span> bkmkStart = builder.indexOf<span class="parenthesis">(</span><span class="string_constant">&quot;\\bkmkstart &quot;</span> + fieldName<span class="parenthesis">)</span>;
<span class="line_number">19</span>        <span class="java_keyword">if</span> <span class="parenthesis">(</span>bkmkStart == -<span class="numeric_constant">1</span>) <span class="java_keyword">return</span> <span class="java_keyword">false</span>;
<span class="line_number">20</span>
<span class="line_number">21</span>        <span class="java_primitive_type">int</span> fldrsltStart = builder.indexOf<span class="parenthesis">(</span><span class="string_constant">&quot;\\fldrslt&quot;</span>, bkmkStart<span class="parenthesis">)</span>;
<span class="line_number">22</span>        <span class="java_keyword">if</span> <span class="parenthesis">(</span>fldrsltStart == -<span class="numeric_constant">1</span>) <span class="java_keyword">return</span> <span class="java_keyword">false</span>;
<span class="line_number">23</span>
<span class="line_number">24</span>        <span class="java_primitive_type">int</span> start = builder.indexOf<span class="parenthesis">(</span><span class="string_constant">&quot;{&quot;</span>, fldrsltStart<span class="parenthesis">)</span>;
<span class="line_number">25</span>        <span class="java_keyword">if</span> <span class="parenthesis">(</span>start == -<span class="numeric_constant">1</span>) <span class="java_keyword">return</span> <span class="java_keyword">false</span>;
<span class="line_number">26</span>
<span class="line_number">27</span>        <span class="java_primitive_type">int</span> end = builder.indexOf<span class="parenthesis">(</span><span class="string_constant">&quot;}&quot;</span>, fldrsltStart<span class="parenthesis">)</span>;
<span class="line_number">28</span>        <span class="java_keyword">if</span> <span class="parenthesis">(</span>end == -<span class="numeric_constant">1</span>) <span class="java_keyword">return</span> <span class="java_keyword">false</span>;
<span class="line_number">29</span>
<span class="line_number">30</span>        builder.replace<span class="parenthesis">(</span>builder.indexOf<span class="parenthesis">(</span><span class="string_constant">&quot; &quot;</span>, start<span class="parenthesis">)</span> + <span class="numeric_constant">1</span>, end, fieldValue<span class="parenthesis">)</span>;
<span class="line_number">31</span>        <span class="java_keyword">return</span> <span class="java_keyword">true</span>;
<span class="line_number">32</span>    <span class="parenthesis">}</span>
<span class="line_number">33</span>
<span class="line_number">34</span>    <span class="java_keyword">public</span> <span class="java_primitive_type">byte</span><span class="parenthesis">[]</span> getBytes<span class="parenthesis">()</span> <span class="parenthesis">{</span>
<span class="line_number">35</span>        <span class="java_keyword">return</span> builder.toString<span class="parenthesis">()</span>.getBytes<span class="parenthesis">()</span>;
<span class="line_number">36</span>    <span class="parenthesis">}</span>
<span class="line_number">37</span>
<span class="line_number">38</span>    <span class="java_keyword">public</span> <span class="java_primitive_type">void</span> launchMSWord<span class="parenthesis">()</span> <span class="java_keyword">throws</span> IOException <span class="parenthesis">{</span>
<span class="line_number">39</span>        runMSWord<span class="parenthesis">(</span>saveTempFile<span class="parenthesis">())</span>;
<span class="line_number">40</span>    <span class="parenthesis">}</span>
<span class="line_number">41</span>
<span class="line_number">42</span>    <span class="java_keyword">private</span> String saveTempFile<span class="parenthesis">()</span> <span class="java_keyword">throws</span> IOException <span class="parenthesis">{</span>
<span class="line_number">43</span>        String tmpDir = System.getProperties<span class="parenthesis">()</span>.getProperty<span class="parenthesis">(</span><span class="string_constant">&quot;java.io.tmpdir&quot;</span><span class="parenthesis">)</span>;
<span class="line_number">44</span>        <span class="java_primitive_type">long</span> time = System.currentTimeMillis<span class="parenthesis">()</span>;
<span class="line_number">45</span>        String filename = tmpDir + <span class="string_constant">&quot;print_&quot;</span> + time + <span class="string_constant">&quot;.rtf&quot;</span>;
<span class="line_number">46</span>
<span class="line_number">47</span>        FileOutputStream out = <span class="java_keyword">new</span> FileOutputStream<span class="parenthesis">(</span>filename<span class="parenthesis">)</span>;
<span class="line_number">48</span>        <span class="java_keyword">try</span> <span class="parenthesis">{</span>
<span class="line_number">49</span>            out.write<span class="parenthesis">(</span>getBytes<span class="parenthesis">())</span>;
<span class="line_number">50</span>        <span class="parenthesis">}</span> <span class="java_keyword">finally</span> <span class="parenthesis">{</span>
<span class="line_number">51</span>            out.close<span class="parenthesis">()</span>;
<span class="line_number">52</span>        <span class="parenthesis">}</span>
<span class="line_number">53</span>        <span class="java_keyword">return</span> filename;
<span class="line_number">54</span>    <span class="parenthesis">}</span>
<span class="line_number">55</span>
<span class="line_number">56</span>    <span class="java_keyword">private</span> <span class="java_primitive_type">void</span> runMSWord<span class="parenthesis">(</span>String filename<span class="parenthesis">)</span> <span class="java_keyword">throws</span> IOException <span class="parenthesis">{</span>
<span class="line_number">57</span>        String osName = System.getProperties<span class="parenthesis">()</span>.getProperty<span class="parenthesis">(</span><span class="string_constant">&quot;os.name&quot;</span><span class="parenthesis">)</span>;
<span class="line_number">58</span>        <span class="java_keyword">if</span> <span class="parenthesis">(</span>osName.indexOf<span class="parenthesis">(</span><span class="string_constant">&quot;Windows&quot;</span><span class="parenthesis">)</span> != -<span class="numeric_constant">1</span>) <span class="parenthesis">{</span>
<span class="line_number">59</span>            String command =
<span class="line_number">60</span>                <span class="string_constant">&quot;rundll32 SHELL32.DLL,ShellExec_RunDLL winword &quot;</span> + filename;
<span class="line_number">61</span>            Runtime.getRuntime<span class="parenthesis">()</span>.exec<span class="parenthesis">(</span>command, <span class="java_keyword">null</span>, <span class="java_keyword">null</span><span class="parenthesis">)</span>;
<span class="line_number">62</span>        <span class="parenthesis">}</span> <span class="java_keyword">else</span> <span class="parenthesis">{</span>
<span class="line_number">63</span>            System.out.println<span class="parenthesis">(</span><span class="string_constant">&quot;Not in Windows; open yourself &quot;</span> + filename<span class="parenthesis">)</span>;
<span class="line_number">64</span>        <span class="parenthesis">}</span>
<span class="line_number">65</span>    <span class="parenthesis">}</span>
<span class="line_number">66</span><span class="parenthesis">}</span></span>
</pre>
<p>You construct the RTF object giving an InputStream to the template file; all the job of replacement is made in <tt>set</tt> method, then you can get resulting bytes with <tt>getBytes()</tt>, or just call <tt>launchMSWord()</tt> if you want to pupup Microsoft Word to the user (this works only on standalone applications).<br />
The above code is a slow prototype, as string search and replacement is made in the easiest way for this post to be simple to understand and to read, so I made a much faster version (that also check to not making mess with the rtf code) that you can find at <a href="http://newinstance-util.googlecode.com/svn/trunk/util/src/it/newinstance/util/rtf/RTF.java">this link</a>. I used this class with very big and complex msword templates containing images, tables, etc. without problems.<br />
A thing that should be added to this class, is character escaping: I didn&#8217;t implemented it yet.</p>
<p>Here&#8217;s an example of usage:</p>
<pre class="java" style="height: 192px"><span class="line_number"> 1</span><span class="code">String resourceName = <span class="string_constant">&quot;/sample-module.rtf&quot;</span>;
<span class="line_number"> 2</span>RTF rtf = <span class="java_keyword">new</span> RTF<span class="parenthesis">(</span>Sample.<span class="java_keyword">class</span>.getResourceAsStream<span class="parenthesis">(</span>resourceName<span class="parenthesis">))</span>;
<span class="line_number"> 3</span>
<span class="line_number"> 4</span>rtf.set<span class="parenthesis">(</span><span class="string_constant">&quot;name&quot;</span>, <span class="string_constant">&quot;Foo&quot;</span><span class="parenthesis">)</span>;
<span class="line_number"> 5</span>rtf.set<span class="parenthesis">(</span><span class="string_constant">&quot;surname&quot;</span>, <span class="string_constant">&quot;Bar&quot;</span><span class="parenthesis">)</span>;
<span class="line_number"> 6</span>rtf.set<span class="parenthesis">(</span><span class="string_constant">&quot;birthday&quot;</span>, <span class="string_constant">&quot;10/10/2010&quot;</span><span class="parenthesis">)</span>;
<span class="line_number"> 7</span>rtf.set<span class="parenthesis">(</span><span class="string_constant">&quot;address&quot;</span>, <span class="string_constant">&quot;Sample Test Address&quot;</span><span class="parenthesis">)</span>;
<span class="line_number"> 8</span>rtf.set<span class="parenthesis">(</span><span class="string_constant">&quot;phone&quot;</span>, <span class="string_constant">&quot;+010 010101010&quot;</span><span class="parenthesis">)</span>;
<span class="line_number"> 9</span>rtf.set<span class="parenthesis">(</span><span class="string_constant">&quot;test&quot;</span>, <span class="string_constant">&quot;testtesttest&quot;</span><span class="parenthesis">)</span>;
<span class="line_number">10</span>
<span class="line_number">11</span>rtf.launchMSWord<span class="parenthesis">()</span>;</span>
</pre>
<p>As for the <a href="http://it.newinstance.it/2006/11/03/excel-file-generation-made-easyer/">excel example</a>, this class can be used in web applications using application/msword content type, so that the browser will associate the file to word.</p>
<p>For a runnable example, I put an eclipse project on subversion with some of my stuff, at this URL:<br />
<a href="http://newinstance-util.googlecode.com/svn/trunk/util/">http://newinstance-util.googlecode.com/svn/trunk/util/</a><br />
After opening the project in eclipse, the class to launch is<br />
<a href="http://newinstance-util.googlecode.com/svn/trunk/util/src/it/newinstance/util/rtf/Sample.java">src/it/newinstance/util/rtf/Sample.java</a><br />
No junit testcases, sorry :-)<br />
The template is located under the <a href="http://newinstance-util.googlecode.com/svn/trunk/util/resources/">resources</a> folder.</p>
<p>The advantage of using this template-based approach over java-api based generation, is that you can take a template from the user and achieve a document that fully respects the given layout. Also you can easily handle layout change.<br />
Doing document generation using a programming language is much more a matter of art than document layout design.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2008/10/24/always-on-getter-and-setters/" rel="bookmark" class="crp_title">Always on getter and setters</a></li>
<li><a href="http://en.newinstance.it/2008/11/04/dynamic-tests-with-junit-3/" rel="bookmark" class="crp_title">Dynamic tests with JUnit 3</a></li>
<li><a href="http://en.newinstance.it/2008/10/24/the-repetita-juvant-principle/" rel="bookmark" class="crp_title">The Repetita Juvant Principle</a></li>
<li><a href="http://en.newinstance.it/2006/11/19/reading-javadocs-from-inside-the-original-zip-file/" rel="bookmark" class="crp_title">Reading Javadocs from inside the original zip file</a></li>
<li><a href="http://en.newinstance.it/2008/11/22/random-thoughts-about-unchecked-exceptions/" rel="bookmark" class="crp_title">Random thoughts about unchecked exceptions</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2007/03/23/msword-generation-made-easyer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
