<?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>Thoughts Electrique &#187; Tutorial</title>
	<atom:link href="http://www.sebastian.himberger.de/blog/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sebastian.himberger.de/blog</link>
	<description>Sebastian Himbergers blog about technology and software development</description>
	<lastBuildDate>Sat, 16 Jul 2011 22:48:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Decentralized categories in OpenCms 7.5</title>
		<link>http://www.sebastian.himberger.de/blog/2009/11/06/decentralized-categories-in-opencms-7-5/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/11/06/decentralized-categories-in-opencms-7-5/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 19:33:26 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Content]]></category>
		<category><![CDATA[CRE]]></category>
		<category><![CDATA[OpenCms]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=417</guid>
		<description><![CDATA[This feature was presented by Michael Emmerich during the OpenCms Days 2009 and caused a lot of people to grab their pen. A short background on categories Categories are a built-in content relation in OpenCms and allow files in the VFS to be assigned one or more topics/keywords/whatever. They can often be used as a [...]]]></description>
			<content:encoded><![CDATA[<p>This feature was presented by <a href="http://www.opencms-days.org/en/program/sessions/t8.html" target="_blank">Michael Emmerich during the OpenCms Days 2009</a> and caused a lot of people to grab their pen.</p>
<h3>A short background on categories</h3>
<p><em>Categories </em>are a built-in content <em>relation</em> in <em>OpenCms</em> and allow files in the <em>VFS</em> to be assigned one or more topics/keywords/whatever. They can often be used as a replacement feature for siblings which are mostly misunderstood by users without a technical background. For example consider the typical example of a news site. You have a folder structure for your articles which could be the following way:</p>
<pre>/articles/2008/12-24-merry-christmas.html
/articles/2009/09-01-new-site.html
/articles/2009/10-02-a-great-article.html</pre>
<p>You now want to categorize the articles into topics so you would create another folder structure:</p>
<pre>/topic/must-read
/topic/technical</pre>
<p>The <em>sibling-way</em> would be to create a sibling (put simply: an automatically updating copy) of the articles in the desired <em>topic</em> folder. While this is a working solution it&#8217;s counterintuitive to most users. OpenCms 7 introduced the long awaited <em>Content Relation Engine</em> (<em>CRE</em>) including a default relation called categories. Similar to the sibling solution a category is effectively a folder but instead of creating it anywhere in the filesystem it&#8217;s created in the root site (&#8220;/&#8221;) under <em>/system/categories/.</em> Users can now assign categories to VFS files using the context-menu entry <em>Relations -&gt; Assign Categories</em>. This is a much easier approach although it has one caveat: Categories are globally defined in the <em>/system/</em> folder and can therefore only be created by users with access to the root site and can not be specified on a per site or even per folder basis. This can cause problems in multisite environments.</p>
<h3>Decentralization to the rescue</h3>
<p>With OpenCms 7.5 this limitation is finally gone. You can now define categories on a per-site and even per-folder basis. Simply create a folder named <em>_categories</em> in the folder where you want the categories to be available. Then create new folders inside this folder to define categories. The categories are available in the parent folder of the <em>_categories</em>-folder and all subfolders. They also cascade down. Example:</p>
<pre>/de/_categories/
/de/_categories/hot-topic
/de/_categories/support
/de/news/_categories/
/de/news/_categories/marketing
/de/news/_categories/development</pre>
<p>Inside the <em>/de/</em> folder the categories <em>hot-topic</em> and <em>support </em>are available. Inside<em> /de/news/</em> the categories <em>hot-topic</em>, <em>support</em>, <em>marketing</em> and <em>development</em> are available.</p>
<p>This feature should easily help you to get your content structured more nicely. Speaking from experience it is crucial to create an evolveable content structure upfront so your editors as well as visitors and search engines get the most out of your site.</p>
<p>See also:</p>
<ul>
<li><a href="http://www.opencms.org/en/events/opencms_days_2008/program/sessions/t2.html" target="_blank">Presentation from Michael Moossen about the CRE at OpenCms Days 2008</a></li>
<li><a href="http://www.w3.org/Provider/Style/URI" target="_blank">A guide to good URI design</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/11/06/decentralized-categories-in-opencms-7-5/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Updating a broken SME 7.1 Server to version 7.4</title>
		<link>http://www.sebastian.himberger.de/blog/2009/10/23/updating-a-broken-sme-7-1-server-to-version-74/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/10/23/updating-a-broken-sme-7-1-server-to-version-74/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 03:06:49 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SME]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=542</guid>
		<description><![CDATA[The SME Server is a great Linux distribution for small to medium sized businesses. I&#8217;ve been doing some emergency sysadmin stuff quite a while ago and encountered the upgrade-hell from 7.1 to version 7.4. Since updating the operating system from 7.1 to 7.4 wasn&#8217;t easy I decided to write a quick blog post to save [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-555" style="border: none; float: left; margin: 4px;" title="The SME Logo" src="http://www.sebastian.himberger.de/blog/wp-content/uploads/2009/10/sme-logo.png" alt="The SME Logo" width="150" height="141" />The <a title="SME Server website" href="http://wiki.contribs.org/Main_Page" target="_blank">SME Server</a> is a great Linux distribution for small to medium sized businesses. I&#8217;ve been doing some emergency sysadmin stuff quite a while ago and encountered the upgrade-hell from 7.1 to version 7.4. Since updating the operating system from 7.1 to 7.4 wasn&#8217;t easy I decided to write a quick blog post to save you from tinkering.</p>
<p><span id="more-542"></span></p>
<p>Updating the SME in general is pretty straighforward but if the customer made modifications to the <em>yum</em> configuration it can quickly turn into a nightmare. Luckily there <a title="Upgrading from 7.1 Tutorial" href="http://wiki.contribs.org/Updating_from_SME_7.1.x_or_earlier#Yum_Update" target="_blank">is a tutorial available in the SME Wiki</a> which can help you to get started. Unfortunately the yum installation was completly broken so I had to update the packages by hand. I pulled the packages from the SME repository at and installed them via</p>
<pre class="terminal">export SME_MIRROR_URL="http://mirror.jvsnet.ro/sme/releases/7/smeos/i386/SME/RPMS"

wget $SME_MIRROR_URL/dialog-1.0.20040731-3.i386.rpm
wget $SME_MIRROR_URL/python-sqlite-1.1.7-1.2.1.i386.rpm
wget $SME_MIRROR_URL/yum-metadata-parser-1.0-8.el4.centos.i386.rpm
wget $SME_MIRROR_URL/e-smith-formmagick-2.0.0-1.el4.sme.noarch.rpm
wget $SME_MIRROR_URL/smeserver-yum-2.0.0-4.el4.sme.noarch.rpm
wget $SME_MIRROR_URL/yum-plugin-fastestmirror-0.2.4-3.c4.noarch.rpm
wget $SME_MIRROR_URL/e-smith-lib-2.0.0-1.el4.sme.noarch.rpm
wget $SME_MIRROR_URL/sqlite-3.3.6-2.i386.rpm
wget $SME_MIRROR_URL/yum-plugin-installonlyn-0.91-1.el4.sme.noarch.rpm
wget $SME_MIRROR_URL/perl-CGI-FormMagick-0.92-16.el4.sme.noarch.rpm
wget $SME_MIRROR_URL/yum-2.4.3-4.el4.centos.noarch.rpm

rpm -Uvh --nodeps --force *.rpm</pre>
<p>You maybe have to adjust this mirror url. This is why I factored it out into a seperate variable.</p>
<p>After this you should reset your <em>yum</em> repositories and clean the <em>yum</em> cache.</p>
<pre class="terminal">cd /home/e-smith/db/
mv yum_repositories yum_repositories.po
/etc/e-smith/events/actions/initialize-default-databases
signal-event yum-modify
yum clean all</pre>
<p>After doing so, issue the following commands to let <em>SME</em> rewrite it&#8217;s config.</p>
<pre class="terminal">signal-event post-upgrade; signal-event reboot</pre>
<p>Now you can update <em>yum</em> through yum itself (I know this sounds strange but this second update helps to get all the GPG keys for the repositories right).</p>
<pre class="terminal">yum update yum
signal-event post-upgrade; signal-event reboot</pre>
<p>Now you can proceed with a normal update to get the whole system up to 7.4. I had to do this following process twice because the updates seem to have pulled in some new dependencies which in turn have to get updated.</p>
<pre class="terminal">yum update yum
signal-event post-upgrade; signal-event reboot</pre>
<p>That&#8217;s it. I&#8217;m sure there might be an easier way but at least these are the steps the helped me get the system up to date. If you have questions just leave me a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/10/23/updating-a-broken-sme-7-1-server-to-version-74/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PHP / PECL ImageMagick extension on 1&amp;1 managed server</title>
		<link>http://www.sebastian.himberger.de/blog/2009/09/26/installing-php-pecl-imagemagick-extension-on-11-managed-server/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/09/26/installing-php-pecl-imagemagick-extension-on-11-managed-server/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 03:42:16 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[1und1]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PECL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=477</guid>
		<description><![CDATA[I once had to install a custom PHP extension on a 1&#38;1 managed server. In this case the company had already purchased a managed server which was running the corporate website. They wanted to install an extranet-like webapplication which needed the ImageMagick PHP extension. In the following post I will outlike how I compiled and [...]]]></description>
			<content:encoded><![CDATA[<p>I once had to install a custom PHP extension on a <a title="1&amp;1 website" href="http://www.oneandone.com" target="_blank">1&amp;1</a> managed server. In this case the company had already purchased a managed server which was running the corporate website. They wanted to install an extranet-like webapplication which needed the <a title="ImageMagick extension" href="http://us3.php.net/manual/en/book.imagick.php">ImageMagick PHP extension</a>. In the following post I will outlike how I compiled and installed this extension on the managed server without having administrative access.</p>
<p><span id="more-477"></span></p>
<h3>Preparation</h3>
<p>To make the approach more modular we will use an environment variable pointing to our htdocs directory. I will call this variable $HTDOCS.</p>
<pre class="terminal">export HTDOCS=/kunden/homepages/.../htdocs</pre>
<p>We can check if everything is correct by changing into the htdocs directory.</p>
<pre class="terminal">cd $HTDOCS</pre>
<p>We will now create two directories:</p>
<ul>
<li><em>$HTDOCS/linux-src</em>: To hold all the data we need to compile the extensionn</li>
<li><em>$HTDOCS/linux</em>: To hold all the compiled data</li>
</ul>
<p>This setup allows us to delete the linux-src directory after we finished compiling the extension and save some diskspace.</p>
<pre class="terminal">mkdir -p $HTDOCS/linux-src
mkdir -p $HTDOCS/linux</pre>
<p>Now we will download the required sourcecode into our working directory:</p>
<pre class="terminal">mkdir -p $HTDOCS/linux-src/download
cd $HTDOCS/linux-src/download
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
wget ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.8.2.tar.gz
wget http://us3.php.net/get/php-5.2.10.tar.gz/from/us.php.net/mirror</pre>
<p><strong>Note:</strong> The URLs to the latest versions may change over time. You will have to adjust them and also watch for changed file names in the following steps. Also be sure to use the PHP version currently active on your managed server.</p>
<h3>Extracting the sourcecode</h3>
<p>Now create a folder for the extracted sourcecode and extract the source archives:</p>
<pre class="terminal">mkdir -p $HTDOCS/linux-src/extracted/imagick
mkdir -p $HTDOCS/linux-src/extracted/php-imagick
mkdir -p $HTDOCS/linux-src/extracted/libtiff
mkdir -p $HTDOCS/linux-src/extracted/php5

cd $HTDOCS/linux-src/extracted/imagick &amp;&amp; tar xfz $HTDOCS/linux-src/download/ImageMagick.tar.gz
cd $HTDOCS/linux-src/extracted/php-imagick &amp;&amp; tar xfz $HTDOCS/linux-src/download/imagick-2.3.0.tgz
cd $HTDOCS/linux-src/extracted/libtiff &amp;&amp; tar xfz $HTDOCS/linux-src/download/tiff-3.8.2.tar.gz
cd $HTDOCS/linux-src/extracted/php5 &amp;&amp; tar xfz $HTDOCS/linux-src/download/php-5.2.10.tar.gz</pre>
<h3>Building delegate libraries</h3>
<p>ImageMagick uses different delegate libraries for certain formats. We have to build these first so they can be incorporated into our ImageMagick build. In this case we will only use libtiff to allow the usage of the TIFF image format.</p>
<h4>Building libtiff from source</h4>
<p>Building libtiff is pretty straightforward. Simply use the following commands inside the extracted source archive:</p>
<pre class="terminal">./configure --prefix=$HTDOCS/linux/
make
make install</pre>
<h3>Building ImageMagick from source</h3>
<p>Change into the extracted source directory and type in the following:</p>
<pre class="terminal">./configure --without-perl --prefix=$HTDOCS/linux \
  CPPFLAGS="-I$HTDOCS/linux/include" LDFLAGS="-L$HTDOCS/linux/lib/"
make
make install</pre>
<p>You can type the following command to test the compiled ImageMagick.</p>
<pre class="terminal">make check</pre>
<p>After ImageMagick is built we can now go on and create the PHP extension.</p>
<h3>Building the ImageMagick PHP extenstion</h3>
<p>To compile the extension we have to have a PHP development environment in place. To create one we&#8217;ll simply compile and install PHP (this sounds more scary than it is).</p>
<h4>Building PHP from source</h4>
<p>Change into the extracted PHP archive and type in the following:</p>
<pre class="terminal">./configure --prefix=$HTDOCS/linux
make
make test
make install</pre>
<p>The <em>make test</em> target will run the PHP test suite. You can expect some tests to fail but if the number of failing tests is overwhelming you should get suspicious.</p>
<h4>Building the ImageMagick PECL extension</h4>
<p>Change into the extracted source archive and type in the following:</p>
<pre class="terminal">phpize --clean
phpize
./configure --prefix=$HTDOCS/linux --with-php-config=/usr/bin/php-config5 --with-imagick=$HTDOCS/linux</pre>
<p>The configure script should go through. Unfortunately it seems that the prefix and paths will not be set correctly in the <em>Makefile</em>. We will have to adjust this and replace the /usr/local paths with the path to our $HTDOCS/linux</p>
<pre class="terminal">echo "$HTDOCS/linux" | sed -e 's/\//\\\//g' &gt; htdocs_pattern &amp;&amp; \
  export HTDOCS_PATTERN=`cat htdocs_pattern` &amp;&amp; rm htdocs_pattern
perl -pi -e "s/\/usr\/local/$HTDOCS_PATTERN/g" Makefile</pre>
<p><strong>Note</strong>: The above command looks a bit freaky and is a bit of a quick hack. What it basically does it is escaping the slashes (/) in the <em>$HTDOCS</em> path and writing this to a file. Then exporting the content of the file to an environment variable and deleting the file. After this PERL is used to replace all <em>/usr/local</em> paths in the <em>Makefile</em> to <em>$HTDOCS/linux</em></p>
<p>After that we are good to go and can build the extension:</p>
<pre class="terminal">./configure --prefix=$HTDOCS/linux
make
make install</pre>
<p>Now the extension should be build successfully and is placed in the directory <em>$HTDOCS/linux/somepath</em> (the <em>make install</em> will tell you the extact path) . The last thing we have to do is activating the extension.</p>
<h3>Activating the extension</h3>
<p>To activate the extension for a certain folder, create a file named php.ini (for example in the $HTDOCS directory) with the following content inside the folder:</p>
<pre class="file">extension_dir=$HTDOCS/linux/somepath
extension=imagick.so</pre>
<p>Also don&#8217;t forget to activate PHP 5 with using a <em>.htaccess</em> file:</p>
<pre class="file">AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php</pre>
<p>That&#8217;s all. If you have any questions feel free to comment. I hope this helps some of you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/09/26/installing-php-pecl-imagemagick-extension-on-11-managed-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up XWiki in Tomcat and MySQL</title>
		<link>http://www.sebastian.himberger.de/blog/2009/09/10/setting-up-xwiki-in-tomcat-and-mysql/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/09/10/setting-up-xwiki-in-tomcat-and-mysql/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 13:32:34 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[XWiki]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=468</guid>
		<description><![CDATA[I recently set up a new XWiki 2.0 instance (with MySQL) for documentation purposes. Although some of the steps are already described in the XWiki manual I&#8217;ll document it here mainly because I keep forgetting things. Also step-by-step tutorials come in handy when you&#8217;re in a hurry. Create the webapp directory Since the configuration files [...]]]></description>
			<content:encoded><![CDATA[<p>I recently set up a new <a title="XWiki Enterprise website" href="http://enterprise.xwiki.org" target="_blank">XWiki 2.0</a> instance (with MySQL) for documentation purposes. Although some of the steps are already described in the XWiki manual I&#8217;ll document it here mainly because I keep forgetting things. Also step-by-step tutorials come in handy when you&#8217;re in a hurry.</p>
<p><span id="more-468"></span></p>
<h3><strong>Create the webapp directory</strong></h3>
<p>Since the configuration files have to be modified an exploded WAR has to be used. The webapp directory has to be created and the WAR will be extracted inside of it.</p>
<pre class="terminal">mkdir xwiki &amp;&amp; cd xwiki
unzip ../xwiki.war
rm ../xwiki.war</pre>
<h3><strong>Create and configure a database</strong></h3>
<p>Create a database including a dedicated database user. Open the file <em>WEB-INF/hibernate.cfg.xml</em> and uncomment the MySQL block. Modify the following properties:</p>
<ul>
<li>connection.username</li>
<li>connection.password</li>
<li>connection.url</li>
</ul>
<p><strong>Important:</strong> Don&#8217;t forget to add the <a title="MySQL JDBC Connector" href="http://dev.mysql.com/downloads/connector/j/" target="_blank">MySQL JDBC driver</a> to your classpath (e.g. WEB-INF/lib).</p>
<p><strong>Note: </strong>It is of course also possible to use a container managed DataSource via JNDI.</p>
<h3><strong>Configure Logfile</strong></h3>
<p>Since the security manager restricts file IO to the webapp directory the logging has to be reconfigured. To do so the <em>log4.properties</em> file has to be copied from <em>xwiki-core-2.0-milestone-4.jar</em> to the <em>WEB-INF/classes</em> directory. After this the property <em>log4j.appender.file.File</em> has to be modified to point to a writeable path.</p>
<h3><strong>Add the context file to Tomcat</strong></h3>
<p>Add a file name <em>${context}.xml</em> to the <em>/conf/Catalina/localhost</em>&#8221; directory of <em>$CATALINA_HOME</em> (the Tomcat instance) and put the following content into it:</p>
<pre class="file">&lt;Context path="<strong>${contextPath}</strong>" docBase="<strong>${pathToWebapp}</strong>" &gt;&lt;/Context&gt;</pre>
<p>Eventually put in references to resources like DataSource&#8217;s etc.</p>
<h3><strong>Create the proxy settings in Apache HTTPD</strong></h3>
<p>You can use any proxy settings. I&#8217;m currently using a very simple setup:</p>
<pre class="file">&lt;Proxy ajp://localhost:10709*&gt;
  Allow from all
&lt;/Proxy&gt;

RewriteEngine On
RewriteRule ^/$ /<em>xwiki</em>/ [R=301,L]

ProxyPass        /      ajp://localhost:10709/
ProxyPassReverse /      ajp://localhost:10709/</pre>
<p><strong>Note:</strong> <em>xwiki </em>is the contextPath</p>
<h3><strong>Test the installation</strong></h3>
<p>Surf to http://www.yourdomain.com/. An empty XWiki page should be displayed. The first step should always be to register a user so the administration area is accessible. The default content can be imported by using the page <em>/${contextPath}/bin/import/XWiki/XWikiPreferences</em>.</p>
<p>I&#8217;ll probably blog more about XWiki and how to customize it in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/09/10/setting-up-xwiki-in-tomcat-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restrict visibility of OpenCms templates to certain folders</title>
		<link>http://www.sebastian.himberger.de/blog/2009/06/03/restrict-visibility-of-opencms-templates-to-certain-folders/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/06/03/restrict-visibility-of-opencms-templates-to-certain-folders/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 15:51:26 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OpenCms]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=401</guid>
		<description><![CDATA[Since I&#8217;m currently working on an OpenCms mutli site solution I was looking for a possibility to restrict the available templates of a site. I know this can be done via permissions but the manual implementation of this is rather painful. I&#8217;m currently in the process of extending the OpenCms security manager to take care [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m currently working on an OpenCms mutli site solution I was looking for a possibility to restrict the available templates of a site. I know this can be done via permissions but the manual implementation of this is rather painful. I&#8217;m currently in the process of extending the OpenCms security manager to take care of this but while doing this I found an (to me) unknown feature.</p>
<p>By usage of the property <em>folders.available</em> (you might have to define it first) on a template you can specify a list of comma seperated folders in which the template is available (in the dropdown).</p>
<p>Unfortunately this property works only on file level and can not be inherited via the folder hierarchy. Also it does not provide a secure solution since the template can always be set via the advanced property dialog.</p>
<p>But you never know when a feature could come in handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/06/03/restrict-visibility-of-opencms-templates-to-certain-folders/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom php.ini and URL rewriting in Plesk 9 with fastcgi</title>
		<link>http://www.sebastian.himberger.de/blog/2009/03/19/custom-phpini-and-url-rewriting-in-plesk-9-with-fastcgi/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/03/19/custom-phpini-and-url-rewriting-in-plesk-9-with-fastcgi/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 17:43:42 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=366</guid>
		<description><![CDATA[For a current hosting server I&#8217;m using the Plesk control panel 9.0.1 for Ubuntu 8.04. Since version 9 Plesk allows the usage of Postfix as an MTA and PHP via FastCGI. This is very nice and much more secure than the old model using mod_php. The Problem One problem with the current Plesk version (as [...]]]></description>
			<content:encoded><![CDATA[<p>For a current hosting server I&#8217;m using the <a title="Official Plesk website" href="http://www.parallels.com/de/products/plesk/" target="_blank">Plesk control panel 9.0.1</a> for Ubuntu 8.04. Since version 9 Plesk allows the usage of <a title="Postfix website" href="http://www.postfix.org/" target="_blank">Postfix</a> as an <a title="Mail Transfer Agent explain at Wikipedia" href="http://en.wikipedia.org/wiki/Mail_Transfer_Agent" target="_blank">MTA</a> and PHP via <a title="FastCGI website" href="http://www.fastcgi.com/" target="_blank">FastCGI</a>. This is very nice and much more secure than the old model using mod_php.</p>
<h3>The Problem</h3>
<p>One problem with the current Plesk version (as with most Plesk versions :/) is that it has some nasty bugs. For example mod_rewrite doesn&#8217;t work with the FastCGI configuration. The problem is that the generated virtual host configuration has a small but important problem. The generated host looks something like this:</p>
<pre class="file">&lt;VirtualHost 88.198.164.10:80&gt;
  ServerName   playground.himberger.de:80
  ServerAlias  www.playground.himberger.de

  &lt;IfModule mod_fcgid.c&gt;
    &lt;Files ~ (\.php)&gt;
      SetHandler fcgid-script
      FCGIWrapper /usr/bin/php5-cgi .php
<strong>      Options ExecCGI</strong>
      allow from all
    &lt;/Files&gt;
  &lt;/IfModule&gt;
&lt;/VirtualHost&gt;</pre>
<p>The issue with this configuration is the line &#8220;<strong>Options ExecCGI</strong>&#8220;. This line enables the execution of CGI scripts for this particular directory but overrides all the Options set earlier. These are in parts needed for mod_rewrite. To fix this the line should be &#8220;<strong>Options +ExecCGI</strong>&#8220;. Sadly changing the configuration doesn&#8217;t help because at the next opportunity Plesk will regenerate the config file and your change is gone.</p>
<p>Luckily there is a way around this&#8230;</p>
<p><span id="more-366"></span></p>
<h3>Enable mod_rewrite (the solution)</h3>
<p>Luckily Plesk allows you to append a custom configuration to the virtual host by creating a file <em>vhost.conf</em> in the <em>${yourvhost}/conf</em> directory. By putting the following config in your <em>vhost.conf</em> you can take back the overwritten Options (don&#8217;t forget to restart the Apache HTTPD).</p>
<pre class="file">&lt;Directory "/var/www/vhosts/${yourvhost}/httpdocs"&gt;
  &lt;Files ~ (\.php)&gt;
    Options All
  &lt;/Files&gt;
&lt;/Directory&gt;</pre>
<p>You have to be very specific (using the enclosing Directory directive) to cause the current setting to be overridden.</p>
<p>With this knowledge at hand we can do some other nice tricks.</p>
<h3>Using a custom php.ini with fastcgi</h3>
<p>Since we are now able to override the Plesk generated configuration we can also alter the fastcgi command and for example specify a custom php.ini:</p>
<pre class="file">&lt;Directory "/var/www/vhosts/${yourvhost}/httpdocs"&gt;
  &lt;Files ~ (\.php)&gt;
   <strong> FCGIWrapper "/usr/bin/php5-cgi -c /etc/phpconfigs/${yourvhost}"  .php</strong>
    Options All
  &lt;/Files&gt;
&lt;/Directory&gt;</pre>
<p>The <strong><strong>FCGIWrapper</strong></strong> command will use the directory specified with the <em>-c</em> parameter for it&#8217;s php configuration. Simply put your php.ini in this directory and it will automatically be picked up. This way you can easily use a per customer PHP configuration with fastcgi and Plesk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/03/19/custom-phpini-and-url-rewriting-in-plesk-9-with-fastcgi/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Static IPs and default route on 1und1 CentOS 5 Servers</title>
		<link>http://www.sebastian.himberger.de/blog/2009/03/11/static-ips-and-default-route-on-1und1-centos-5-servers/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/03/11/static-ips-and-default-route-on-1und1-centos-5-servers/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 22:10:19 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[1und1]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=358</guid>
		<description><![CDATA[I&#8217;ve been experiencing some serverdowns at a client who uses 1und1 CentOS 5 Servers. After some investigation I discovered that cronjobs were still running although the server appeared to be down. Checking the syslogs showed me a bunch of failed DHCP requests which remebered me of the fact that 1und1 uses DHCP to configure the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experiencing some serverdowns at a client who uses <a title="1und1 german website" href="http://www.1und1.de" target="_blank">1und1</a> <a title="Official CentOS website" href="http://www.centos.org/" target="_blank">CentOS </a>5 Servers. After some investigation I discovered that cronjobs were still running although the server appeared to be down. Checking the syslogs showed me a bunch of failed DHCP requests which remebered me of the fact that <strong>1und1 uses DHCP to configure the server machines</strong>. I don&#8217;t think this is a good idea so I changed the setup to static IPs.</p>
<p>Since 1und1 puts every server behind a dedicated firewall the setup is not as easy as you think. I&#8217;ll document it here because It may be useful for other people and certainly for myself after a couple of months.</p>
<h3>Configure a static IP address</h3>
<p>Open the file <em>/etc/sysconfig/network-scripts/ifcfg-eth0</em> and edit it to look like the following:</p>
<pre class="file">DEVICE=eth0
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes
HWADDR=$YOURMACADDRESS
NETMASK=255.255.255.255
IPADDR=$YOURIP
GATEWAY=10.255.255.1</pre>
<p>Save the file.</p>
<h3>Configure static routes</h3>
<p>This is the tricky part. Configuring a default gateway using the <em>GATEWAY=</em> setting is not enough. You have to setup the routes yourself. To do so create a new file <em>/etc/sysconfig/network-scripts/route-eth0 </em>with the following contents:</p>
<pre class="file">10.255.255.1 dev eth0
default via 10.255.255.1 dev eth0</pre>
<p>Now you only have to reload the networking configuration via</p>
<pre class="terminal">service network reload</pre>
<p>and you are done!</p>
<p><a title="Tutorial for CentOS4" href="http://webui.sourcelabs.com/centos/mail/user/threads/How_to_create_static_routes_on_startup_with_CentOS4%253F.meta" target="_blank">This post</a> helped me a lot with the solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/03/11/static-ips-and-default-route-on-1und1-centos-5-servers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>OpenCms Apache integration: The simplest solution</title>
		<link>http://www.sebastian.himberger.de/blog/2009/03/11/opencms-apache-integration-the-simplest-solution/</link>
		<comments>http://www.sebastian.himberger.de/blog/2009/03/11/opencms-apache-integration-the-simplest-solution/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 17:28:09 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[OpenCms]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=353</guid>
		<description><![CDATA[My OpenCms Apache Integration Howto for OpenCms 6 still get&#8217;s a lot of visitors. Many things have changed since I first wrote this howto and certainly things are a lot easier now. I always wanted to rewrite the howto but till then I will just publish a short update on how to integrate OpenCms 7 [...]]]></description>
			<content:encoded><![CDATA[<p>My <a title="OpenCms Apache Integration Howto" href="/comp/tutorials/opencms/apache-integration/" target="_blank">OpenCms Apache Integration Howto for OpenCms 6</a> still get&#8217;s a lot of visitors. Many things have changed since I first wrote this howto and certainly things are a lot easier now. I always wanted to rewrite the howto but till then I will just publish a short update on how to integrate OpenCms 7 with Apache and to remove the <em>/opencms</em> prefix with the most recent software.</p>
<p><span id="more-353"></span></p>
<h3>Prerequisites</h3>
<ul>
<li>OpenCms 7 (already installed)</li>
<li>Apache HTTPD 2.2 with mod_proxy_ajp</li>
<li>Apache Tomcat 5.5+</li>
</ul>
<h3>Goal of the setup</h3>
<ul>
<li>Dynamic content served from http://www.yourdomain.com/</li>
<li>Static content served from http://www.yourdomain.com/opencms/export/</li>
</ul>
<h3>Steps to perform</h3>
<h4>Configure Tomcat</h4>
<p>As described in the Howto you have to add the <em>emptySessionPath=&#8221;true&#8221;</em> attribute to the Tomcat AJP Connector in the <em>server.xml</em>:</p>
<pre class="file">&lt;Connector <strong>emptySessionPath="true"</strong> port="8009" protocol="AJP/1.3" /&gt;</pre>
<h4>Configure OpenCms</h4>
<p>You have to modify the <em>opencms-importexport.xml</em> configuration file. But beware the <em>&lt;rfs-prefix&gt;</em> doesn&#8217;t need changing anymore. In fact: Things won&#8217;t work if you change it the old way. These are the settings you want.</p>
<pre class="file">       &lt;rfs-prefix&gt;${CONTEXT_NAME}/export&lt;/rfs-prefix&gt;
       &lt;vfs-prefix&gt;&lt;/vfs-prefix&gt;</pre>
<p>Don&#8217;t forget to restart OpenCms.</p>
<h4>Configure Apache HTTPD</h4>
<p>Since the AJP Connector is now integrated in mod_proxy you don&#8217;t need the (stupid) rewrite rules anymore. I also got rid of the fact that static content is served from Apache. This has several reasons:</p>
<ol>
<li>The new Tomcat is fast enough to serve static content itself. Espcecially with the NIO / APR Connector.</li>
<li>If you ever want to move the Tomcat to a different machine and use Apache HTTPD as a simple load balancer things get a lot easier if Apache doesn&#8217;t need access to the web application files.</li>
</ol>
<p>Here&#8217;s an example virtual host:</p>
<pre class="file">&lt;VirtualHost *:80&gt;

  ServerName yourdomain.com
  DocumentRoot /some/directory

  &lt;Proxy ajp://localhost:8009*&gt;
     Allow from all
  &lt;/Proxy&gt;

  ProxyPass        /opencms/   ajp://localhost:8009/opencms/
  ProxyPassReverse /opencms/   ajp://localhost:8009/opencms/

  ProxyPass /          ajp://localhost:8009/opencms/opencms/
  ProxyPassReverse /   ajp://localhost:8009/opencms/opencms/

&lt;/VirtualHost&gt;</pre>
<p>This is it. Don&#8217;t hesitate to ask questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2009/03/11/opencms-apache-integration-the-simplest-solution/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Use the power of JSP tag files in OpenCms</title>
		<link>http://www.sebastian.himberger.de/blog/2008/12/12/use-the-power-of-jsp-tag-files-in-opencms/</link>
		<comments>http://www.sebastian.himberger.de/blog/2008/12/12/use-the-power-of-jsp-tag-files-in-opencms/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 09:22:38 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[OpenCms]]></category>
		<category><![CDATA[Sourcecode]]></category>
		<category><![CDATA[Taglibs]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=220</guid>
		<description><![CDATA[Since version 7 OpenCms is a Servlet 2.4 and JSP 2.0 conforming application. In addition to the improved expression language (EL) JSP 2.0 also brings in the possibility of developing custom tags(actions) using JSP rather than writing Java code. This allows for some pretty neat things and enables you to go one step further towards [...]]]></description>
			<content:encoded><![CDATA[<p>Since version 7 OpenCms is a <em>Servlet 2.4</em> and <em>JSP 2.0</em> conforming application. In addition to the improved expression language (<em>EL</em>) JSP 2.0 also brings in the possibility of developing custom tags(actions) using JSP rather than writing Java code. This allows for some pretty neat things and enables you to go one step further towards cleaner view code. I&#8217;ve used this in one of my last projects extensively to refactor common code like pagers and link generation. For example:</p>
<pre class="file">&lt;cms:include file="/system/modules/com.example.ocms.commons/elements/pager"&gt;
  &lt;cms:param name="currentPage"&gt;
    &lt;c:out value="${model.currentPage}"/&gt;
  &lt;/cms:param&gt;
  &lt;cms:param name="pageCount"&gt;
    &lt;c:out value="${model.pageCount}"/&gt;
  &lt;/cms:param&gt;
&lt;/cms:include&gt;</pre>
<p>Became:</p>
<pre class="file">&lt;wt:pager model="${model}"/&gt;</pre>
<p>Not does it only look cleaner and is much more focused, it also decouples your view more from the underlying CMS solution. Of course you could also develop a custom tag library using Java (which I have done a few times) but using a JSP the advantage that code can be changed on the fly and even from a web designer. You can always refactor your JSP taglib into a Java one if you need to do it. There are some limitations of JSP tag files (like you can&#8217;t use scriptlets in the body) but they are easy to get around.</p>
<p><strong>But as always:</strong> This is no silver bullet. There are problems with tag files which may not be obvious at the first glance.</p>
<p><span id="more-220"></span></p>
<h3>How to create a tag</h3>
<p>Creating a tag is easy. I will show you the necessary steps while developing a tag which allows the user to loop over the contents of an OpenCms <a href="http://www.opencms-wiki.org/Virtual_File_System">VFS</a> directory.</p>
<h4>Preparing your module</h4>
<p>As normal Java libraries too, JSP tags need to be exported into the filesystem to be read by the <a href="http://en.wikipedia.org/wiki/Java_Servlet#Servlet_containers">Servlet-Container</a>. Normally the tag files reside under a directory like <em>${yourwebapp}/WEB-INF/tags/mylibrary</em>. So what we will do is adding a new export point to the module containing our tag files.</p>
<p>First we create a new directory called <em>tags </em>inside the module we want to contain our tags (normally I create a module for each site). The resulting structure will look something like this</p>
<div id="attachment_227" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/create-tags-folder.png"><img class="size-full wp-image-227" title="The tags folder inside the module directory" src="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/create-tags-folder.png" alt="The tags folder inside the module directory" width="500" height="154" /></a><p class="wp-caption-text">The tags folder inside the module directory</p></div>
<p>Then we open the module administration and add an export point to our module (<em>Administration -&gt;  	<span class="link" onclick="openPage('/system/workplace/views/admin/admin-main.jsp?path=/modules');" onmouseover="sMH('navtool7');" onmouseout="hMH('navtool7');"><span style="white-space: nowrap;">Module Management</span></span> -&gt; Edit Your module -&gt; Module exportpoints -&gt; New exportpoint</em>).</p>
<div id="attachment_228" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/add-exportpoint.png"><img class="size-full wp-image-228" title="Adding the tags exportpoint" src="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/add-exportpoint.png" alt="Adding the tags exportpoint" width="500" height="138" /></a><p class="wp-caption-text">Adding the tags exportpoint</p></div>
<p>After pressing <em>OK</em> we are well prepared to add custom tags to our OpenCms module.</p>
<h4>Creating the tag file</h4>
<p>We now create a directory for our taglib. This will be located inside our newly created <em>tags </em>folder. Because we want to create a tag which interacts with the OpenCms VFS we will simply call the folder <em>vfs</em>. Inside this directory we create a new JSP resource called <em>directoryLoop.tag</em>. The result should look something like this:</p>
<div id="attachment_230" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/the-tag-file.png"><img class="size-full wp-image-230" title="The created tag file in the VFS" src="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/the-tag-file.png" alt="The created tag file in the VFS" width="500" height="57" /></a><p class="wp-caption-text">The created tag file in the VFS</p></div>
<p>Now it&#8217;s time to write some code <img src='http://www.sebastian.himberger.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h4>Writing the tag file</h4>
<p>I don&#8217;t want to go into the details of developing tag files in general. This topic has been covered by dozens of books and online tutorials. I have collected some links in this blog post which explain the development of tag files in detail. Have a look at the section <em>Further reading</em> if you want to find out.</p>
<p>I will assume you&#8217;ve already developed JSP files inside OpenCms so I won&#8217;t explain the steps in detail. If you have questions regarding the sourcecode simply post a comment.</p>
<p>Here&#8217;s the commented sourcecode for our tag file.</p>
<pre class="file">&lt;%@ tag body-content="scriptless" %&gt;
&lt;%@ tag import="org.opencms.jsp.*,
                org.opencms.file.*,
                java.util.*" %&gt;
&lt;%@ attribute name="folder" required="true" %&gt;
&lt;%@ variable name-given="resource" scope="NESTED" %&gt;
&lt;%@ variable name-given="status" scope="NESTED" %&gt;
&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;&lt;%

// First we get the pageContext variable.
// Tag files only have an explicit JspContext but in this case
// it is a PageContext which is a subclass of JspContext.
PageContext pageContext = (PageContext)jspContext;

// Instantiate the usual CmsObject to access OpenCms data
CmsJspActionElement cmsa = new CmsJspActionElement(pageContext ,request,response);
CmsObject cmso = cmsa.getCmsObject();

// Read the resources, note that we can access the tag
// parameters using the pageContext.
String folder = (String) pageContext.getAttribute("folder");
folder = cmso.getRequestContext().removeSiteRoot(folder);
List resources = cmso.readResources(folder,CmsResourceFilter.DEFAULT,false);

// We store the list of resources in the pageContext for usage with JSTL
pageContext.setAttribute("resources",resources);

%&gt;

&lt;c:forEach var="resource" items="${resources}" varStatus="status"&gt;
  &lt;jsp:doBody/&gt;
&lt;/c:forEach&gt;</pre>
<p>As you can see the tag file looks like a usual JSP file with only a few differences.</p>
<p>The tag exports two variables: The <em>current resource</em> and the <em>iteration status</em>. These can be accessed from the invoking JSP. We will make use of this in the next example.</p>
<p><strong>To use the tag you have to publish the file</strong> so it gets written to the file system. After you&#8217;re finished writing/modifying the tag: Don&#8217;t forget to publish it!</p>
<p><strong>You can&#8217;t preview tags</strong>, even though they are JSP files. You also won&#8217;t get compiler warnings. You always need a JSP file to test your tag files.</p>
<h4>Using the created tag</h4>
<p>We will use the created tag to implement a simple file browser. The file browser displays the contents of a folder and allows the user to navigate into subfolders recursively. Please note that <strong>this is definately no production ready code</strong>.</p>
<pre class="file"><strong>&lt;%@ taglib prefix="vfs" tagdir="/WEB-INF/tags/vfs" %&gt;</strong>
&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;

&lt;%-- Determine the current folder, set to "/" if no parameter given --%&gt;
&lt;c:set var="folder" value="${param.folder}"/&gt;
&lt;c:if test="${folder eq '' or folder == null}"&gt;
  &lt;c:set var="folder" value="/"/&gt;
&lt;/c:if&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;style type="text/css"&gt;

   .row-1 {
     background-color: #ECECEC;
   }

  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Resources of folder "${folder}"&lt;/h1&gt;
&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;&lt;/th&gt;
    &lt;th&gt;Name&lt;/th&gt;
    &lt;th&gt;Size&lt;/th&gt;
    &lt;th&gt;Date created&lt;/th&gt;
  &lt;/tr&gt;
<strong>  &lt;vfs:directoryLoop folder="${folder}"&gt;</strong>
  &lt;%-- We use the status for alternating row classes, useful for css --%&gt;
  &lt;tr class="row-${status.count % 2}"&gt;
    &lt;td&gt;
      &lt;%-- Display D for directory or F for file --%&gt;
      &lt;c:choose&gt;
        &lt;c:when test="${resource.folder}" &gt;D&lt;/c:when&gt;
        &lt;c:otherwise&gt;F&lt;/c:otherwise&gt;
      &lt;/c:choose&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;%-- If the current resource is a folder, display a link --%&gt;
      &lt;c:choose&gt;
        &lt;c:when test="${resource.folder}" &gt;
          &lt;a href="?folder=${resource.rootPath}"&gt;${resource.name}&lt;/a&gt;
        &lt;/c:when&gt;
        &lt;c:otherwise&gt;${resource.name}&lt;/c:otherwise&gt;
      &lt;/c:choose&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;%-- If the current resource is a file, display size --%&gt;
      &lt;c:if test="${!resource.folder}"&gt;${resource.length}&lt;/c:if&gt;
    &lt;/td&gt;
    &lt;td&gt;${resource.dateCreated}&lt;/td&gt;
  &lt;tr&gt;
<strong>  &lt;/vfs:directoryLoop&gt;</strong>
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>As you can see the tags are included with the directive.</p>
<pre class="file"><strong>&lt;%@ taglib prefix="vfs" tagdir="/WEB-INF/tags/vfs" %&gt;
</strong></pre>
<p>The usage of the tags is similar to normal tags with the exception that you can&#8217;t use scriptlets in the tag bodies. If the example is working you should see something like the following.</p>
<div id="attachment_241" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/ouput.png"><img class="size-full wp-image-241" title="The output of the created JSP" src="http://www.sebastian.himberger.de/blog/wp-content/uploads/2008/12/ouput.png" alt="The output of the created tag" width="500" height="178" /></a><p class="wp-caption-text">The output of the created JSP</p></div>
<p>If you have trouble reading the above code. Here is a more condensed version of a file using the tag:</p>
<pre><strong>&lt;%@ taglib prefix="vfs" tagdir="/WEB-INF/tags/vfs" %&gt;</strong>
&lt;ul&gt;
<strong>&lt;vfs:directoryLoop folder="/system/modules"&gt;</strong>
  &lt;li&gt;${resource.name}&lt;/li&gt;
<strong>&lt;/vfs:directoryLoop&gt;</strong>
&lt;/ul&gt;</pre>
<h3>Things to keep in mind</h3>
<p>JSP tag files and OpenCms really are a nice fit, but before you start working on converting all your custom includes to tag files keep in mind some of the disadvantages of tag files in respect to using <em>&lt;cms:include&gt;</em>.</p>
<ul>
<li><strong>Tag files are not seperated by online/offline</strong>. Since the tag files only get exported during publishing there is no way of developing the tags in the offline project. You always have to publish the tag file to see your changes (It&#8217;s like a normal, Java based, tag library). This means if you have an error in your code the live system will be affected by it. In my opinion this problem is not as big as it sounds. Tags are normally developed in a staged environment or on a developer machine and then deployed on the live server. Additionally they are no replacement for templates and therefore shouldn&#8217;t be changed often.</li>
<li><strong>Tag files are not cached</strong>. The output of a <em>&lt;cms:include&gt;</em> may be cached by the OpenCms FlexCache. This can speed up the rendering enormously, tag files are always processed. In my opinion this no big problem. Tag files will mostly always be used in JSP templates which in turn will be cached by the FlexCache. I would suggtest that tag files are used as the building blocks for JSP templates and therefore are one a finer granular level. The chunks you want to cache are normally much more coarse grained.</li>
</ul>
<h3>Finishing thoughts</h3>
<p>In my opinion JSP tag files are a great thing. They can help you clean up messy JSP templates and nicely decouple your JSPs from OpenCms (although I used a pretty OpenCms heavy example in this post). I hope this post was useful and helped you adding another tool to your toolbox. If you have further questions or need help regarding a specific project, please leave a comment or <a href="/contact">contact me directly</a>.</p>
<h3>Further Reading</h3>
<p>These tutorials can help you developing your own tag files or looking up classes used in this tutorial.</p>
<ul>
<li><a title="Encapsulating Reusable Content Using Tag Files" href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnama.html" target="_blank">The JEE 5 tutorial on creating tag files</a></li>
<li><a title="Creating JSP 2.0 Tag Files" href="http://www.oracle.com/technology/pub/articles/cioroianu_tagfiles.html" target="_blank">An online tutorial on JSP tag files by Oracle</a></li>
<li><a title="Easy Custom Tags with Tag Files" href="http://today.java.net/pub/a/today/2003/11/14/tagfiles.html" target="_blank">A java.net article on tag files, short and good</a></li>
<li><a title="The OpenCms JavaDoc" href="http://files.opencms.org/javadoc/core/" target="_blank">The OpenCms JavaDoc, always handy</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2008/12/12/use-the-power-of-jsp-tag-files-in-opencms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better SEO for external links in OpenCms Navigation</title>
		<link>http://www.sebastian.himberger.de/blog/2008/11/26/better-seo-for-external-links-in-opencms-navigation/</link>
		<comments>http://www.sebastian.himberger.de/blog/2008/11/26/better-seo-for-external-links-in-opencms-navigation/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 14:10:25 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[OpenCms]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Sourcecode]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.sebastian.himberger.de/blog/?p=202</guid>
		<description><![CDATA[The Problem If you put an external link into the OpenCms navigation the resulting link will target the external link file which then in turns redirects the surfer to the external page. This is bad if you really want to optimize your navigation for search engines, because search engines won&#8217;t see the real link inside [...]]]></description>
			<content:encoded><![CDATA[<h3>The Problem</h3>
<p>If you put an external link into the OpenCms navigation the resulting link will target the external link file which then in turns redirects the surfer to the external page. This is bad if you really want to optimize your navigation for search engines, because search engines won&#8217;t see the real link inside the navigation.</p>
<h3>The solution</h3>
<p>You can use the following JSP snippet to get the real URL from a <a href="http://files.opencms.org/javadoc/core/org/opencms/jsp/CmsJspNavElement.html" target="_blank">CmsJspNavElement</a>.</p>
<pre>// We assume that the variable "link" holds an <a href="http://files.opencms.org/javadoc/core/org/opencms/jsp/CmsJspNavElement.html" target="_blank">CmsJspNavElement</a> and
// "cmsa" holds an <a href="http://files.opencms.org/javadoc/core/org/opencms/jsp/CmsJspActionElement.html" target="_blank">CmsJspActionElement</a>.

// Prevent external links from beeing a redirect
// therefore extract the real URL out of the file
String fileUri = link.getResourceName();
CmsResource navResource = cmsa.getCmsObject().readResource(fileUri);
if (navResource.getTypeId() == CmsResourceTypePointer.getStaticTypeId()) {
    CmsFile navFile = CmsFile.upgrade(navResource,cmsa.getCmsObject());
    String externalLink = new String(navFile.getContents());
    externalLink = externalLink.trim();
}</pre>
<h3>Further reading</h3>
<ul>
<li><a href="http://files.opencms.org/javadoc/core/index.html">The OpenCms JavaDoc</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastian.himberger.de/blog/2008/11/26/better-seo-for-external-links-in-opencms-navigation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

