<?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>philihp.com &#187; Programming</title>
	<atom:link href="http://www.philihp.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.philihp.com/blog</link>
	<description>I do things, and then I tell the internet about them.</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:40:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Chained Struts Actions Accessible Only by Forward</title>
		<link>http://www.philihp.com/blog/2012/chained-struts-actions-that-accessible-only-by-forward/</link>
		<comments>http://www.philihp.com/blog/2012/chained-struts-actions-that-accessible-only-by-forward/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 05:40:05 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[Forward]]></category>
		<category><![CDATA[Fragment]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Struts]]></category>
		<category><![CDATA[Struts 1.3]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=961</guid>
		<description><![CDATA[So I just stumbled into doing this little trick. It may go against some pattern, or best practice, but I&#8217;m sure there&#8217;s a use for it somewhere. In Struts 1.3 (and probably any Struts 1.x), it is sometimes useful to have a request chain across multiple Action classes, maybe to break them up into more [...]]]></description>
			<content:encoded><![CDATA[<p>So I just stumbled into doing this little trick. It may go against some pattern, or best practice, but I&#8217;m sure there&#8217;s a use for it somewhere.</p>
<p>In <a href="http://struts.apache.org/1.3.10/">Struts 1.3</a> (and probably any Struts 1.x), it is sometimes useful to have a request chain across multiple Action classes, maybe to break them up into more manageable sections. But maybe you don&#8217;t want step-2 of a multi-Action process be accessible externally. If you configure your Actions like this in your <code>struts-config.xml</code>, you can do just that.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/refresh&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;com.philihp.action.RefreshPartOne&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forward</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;default&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/refresh#2.do&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/refresh#2&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;com.philihp.action.RefreshPartTwo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forward</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;default&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #000066;">redirect</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>To trigger it, have the user goto <code>/refresh.do</code>. Struts will call RefreshPartOne.execute(), and assuming it returns the default ActionForward, it will call RefreshPartTwo.execute().</p>
<p>If the user tries to call <code>/refresh#2.do</code>, they will get an error. The browser will strip out the <a href="http://en.wikipedia.org/wiki/Fragment_identifier">fragment identifier</a> from the URL and tell the server it wants to see /refresh, which doesn&#8217;t exist. It may be possible to carefully craft a request to the server though, and it&#8217;s up to your container (e.g. Tomcat, Glassfish) to strip out the fragment. Behavior is probably undefined because <a href="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738</a> says the &#8216;<code>#</code>&#8216; is unsafe and should never be sent in a URL. So test it out if you&#8217;re really curious.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2012/chained-struts-actions-that-accessible-only-by-forward/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New in Java 7: switch()ing on Strings</title>
		<link>http://www.philihp.com/blog/2012/new-in-java-7-switching-on-strings/</link>
		<comments>http://www.philihp.com/blog/2012/new-in-java-7-switching-on-strings/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 04:49:57 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java 7]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=946</guid>
		<description><![CDATA[Finally, Java can switch on Strings! No more inefficient strings of if/else chains or Hash lookups or translation into Enums. Finally just clean readable and intuitive code. switch&#40;suit&#41; &#123; case &#34;club&#34;: case &#34;diamond&#34;: trickValue = 20; break; case &#34;heart&#34;: case &#34;spade&#34;: trickValue = 30; break; case &#34;no-trump&#34;: trickValue = 40; break; &#125; It&#8217;s actually just [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, <a href="http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html">Java can switch on Strings</a>! No more inefficient strings of if/else chains or Hash lookups or translation into Enums. Finally just clean readable and intuitive code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span>suit<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;club&quot;</span><span style="color: #339933;">:</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;diamond&quot;</span><span style="color: #339933;">:</span>
    trickValue <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;heart&quot;</span><span style="color: #339933;">:</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;spade&quot;</span><span style="color: #339933;">:</span>
    trickValue <span style="color: #339933;">=</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;no-trump&quot;</span><span style="color: #339933;">:</span>
    trickValue <span style="color: #339933;">=</span> <span style="color: #cc66cc;">40</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It&#8217;s actually just syntactic sugar. The <a href="http://blogs.oracle.com/darcy/entry/project_coin_strings_in_switch">java compiler renders this all down to int switching</a> by pre-computing the <code>.hashcode()</code> of all of the labels since they have to be constants anyway (unlike languages like PHP where you can do <a href="http://programmersnotes.info/2009/03/06/trick-with-php-switch/">some really neat shenanigans</a>). Because this still renders down to primitives, Java still gets the <a href="http://en.wikipedia.org/wiki/Jump_table">jump table optimizations</a> that were the whole motivation of the switch construct in the first place.</p>
<p>If you use Eclipse, switching on a String will still probably give you an error. <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=288548#c9">It wasn&#8217;t until September 2011&#8242;s release (3.7.1)</a> that this was implemented. There were versions of Indigo that didn&#8217;t support this, so you&#8217;ll need the latest one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2012/new-in-java-7-switching-on-strings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Create an Empty SAS Dataset</title>
		<link>http://www.philihp.com/blog/2012/how-to-create-an-empty-sas-dataset/</link>
		<comments>http://www.philihp.com/blog/2012/how-to-create-an-empty-sas-dataset/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 07:24:50 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[data step]]></category>
		<category><![CDATA[SAS]]></category>

		<guid isPermaLink="false">http://linode.philihp.com/blog/?p=913</guid>
		<description><![CDATA[If you were to do this in SAS to create an empty SAS dataset: data mytable; run; It would actually create a dataset with one row. The data step cycles through once, hits the end (run), outputs a row, then comes back and finds it has no more rows to process so it stops. To [...]]]></description>
			<content:encoded><![CDATA[<p>If you were to do this in SAS to create an empty SAS dataset:</p>

<div class="wp_syntax"><div class="code"><pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">data</span> mytable;
<span style="color: #000080; font-weight: bold;">run</span>;</pre></div></div>

<p>It would actually create a dataset with one row. The data step cycles through once, hits the end (run), outputs a row, then comes back and finds it has no more rows to process so it stops. To stop this one row from being output, try this instead:</p>

<div class="wp_syntax"><div class="code"><pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">data</span> mytable;
  <span style="color: #0000ff;">stop</span>;
<span style="color: #000080; font-weight: bold;">run</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2012/how-to-create-an-empty-sas-dataset/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Please stop creating links with target=&#8221;_new&#8221;.</title>
		<link>http://www.philihp.com/blog/2011/please-stop-creating-links-with-target_new/</link>
		<comments>http://www.philihp.com/blog/2011/please-stop-creating-links-with-target_new/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 23:33:26 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[new window]]></category>
		<category><![CDATA[target]]></category>
		<category><![CDATA[_blank]]></category>
		<category><![CDATA[_new]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=746</guid>
		<description><![CDATA[Just stop. This is wrong; instead, use this: target="_blank" I don&#8217;t know who started these nasty rumors that &#8220;_new&#8221; would open up in a new browser. As far back as I can tell, no browser has ever recognized &#8220;_new&#8221;. The whole point of the target dates back to when browsers used frames to split up your [...]]]></description>
			<content:encoded><![CDATA[<p>Just stop. This is wrong; instead, use this:</p>
<blockquote><p><code>target="_blank"</code></p></blockquote>
<p>I don&#8217;t know who started these nasty rumors that &#8220;_new&#8221; would open up in a new browser. As far back as I can tell, no browser has ever recognized &#8220;_new&#8221;.</p>
<p>The whole point of the <code>target</code> dates back to when browsers used frames to split up your browser. If you had a link in a sidebar on the left, and you wanted that link to open up in the main frame to the right, you would specify &#8220;main&#8221; as the name of that frame in your frameset page, and target=&#8221;main&#8221; in your links on the sidebar. When the user would click on a link in the sidebar, the browser would say &#8220;hmm, I&#8217;m supposed to open this up in the &#8216;main&#8217; frame, do I have one named that?&#8221;. If it didn&#8217;t, it would open up the link in a new window, and give that window the name of the target of the link. This is what would happen with target=&#8221;_new&#8221;; a new browser would open up with a name of &#8220;_new&#8221;.</p>
<p>The problem is this if you click on this first link, then read it and go &#8220;oh that&#8217;s interesting&#8221; and click on some links in it to goto further pages on it, everything seems fine. But then if you click this second link below, and then the third link, they open up in the same browser!</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Hoag's_Object" target="_new">Link 1</a> target=&#8221;_new&#8221;</li>
<li><a href="http://en.wikipedia.org/wiki/Vlad_III_Dracula" target="_new">Link 2</a> target=&#8221;_new&#8221;</li>
<li><a href="http://en.wikipedia.org/wiki/Jack_(playing_card)#History" target="_new">Link 3</a> target=&#8221;_new&#8221;</li>
</ul>
<p>If only they had a target of &#8220;_blank&#8221;, they would all open up in a new browser every time.</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Hoag's_Object" target="_blank">Link 1</a> target=&#8221;_blank&#8221;</li>
<li><a href="http://en.wikipedia.org/wiki/Vlad_III_Dracula" target="_blank">Link 2</a> target=&#8221;_blank&#8221;</li>
<li><a href="http://en.wikipedia.org/wiki/Jack_(playing_card)#History" target="_blank">Link 3</a> target=&#8221;_blank&#8221;</li>
</ul>
<p>It&#8217;s a simple fix. Just stop using target=&#8221;_new&#8221;.</p>
<blockquote><p>You keep using that word. I do not think it means what you think it means. &#8211; <a href="http://www.imdb.com/title/tt0093779/quotes?qt=qt0482717" target="_blank">Inigo Montoya</a></p></blockquote>
<p>Or just stop opening links in new browsers all together; it has been <a href="http://www.useit.com/alertbox/990530.html">considered bad usability</a> for over a decade now. The user will open your links up in a new window if they want to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/please-stop-creating-links-with-target_new/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Eclipse WTP with Maven&#8217;s eclipse:eclipse Goal</title>
		<link>http://www.philihp.com/blog/2011/using-eclipse-wtp-with-mavens-eclipseeclipse-goal/</link>
		<comments>http://www.philihp.com/blog/2011/using-eclipse-wtp-with-mavens-eclipseeclipse-goal/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 05:45:52 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[wtp]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=735</guid>
		<description><![CDATA[If you use Maven&#8217;s &#8220;eclipse:eclipse&#8221; goal to generate a project descriptor for eclipse, by default you&#8217;re just going to get a plain Java project. You&#8217;ll have to add in the Dynamic Web facet in order to tell Eclipse that you can deploy this project in a web container. The easy way around this is to [...]]]></description>
			<content:encoded><![CDATA[<p>If you use Maven&#8217;s &#8220;eclipse:eclipse&#8221; goal to generate a project descriptor for eclipse, by default you&#8217;re just going to get a plain Java project. You&#8217;ll have to add in the Dynamic Web facet in order to tell Eclipse that you can deploy this project in a web container. The easy way around this is to configure the maven-eclipse-plugin in the pom.xml file like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-eclipse-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wtpContextName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>some/url/context<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wtpContextName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wtpversion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wtpversion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Also, I like to download sources and Javadoc, which makes navigating in Eclipse a lot easier. This can be done like this.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;downloadSources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/downloadSources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;downloadJavadocs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/downloadJavadocs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Supposing you also want your project to have JPA facets, or other additional project facets you could also add them in like this</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;additionalProjectFacets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jpt.jpa<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jpt.jpa<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/additionalProjectFacets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And all of these can be combined to do this</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-eclipse-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wtpContextName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>list<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wtpContextName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wtpversion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wtpversion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;downloadSources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/downloadSources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;downloadJavadocs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/downloadJavadocs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;additionalProjectFacets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jpt.jpa<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jpt.jpa<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/additionalProjectFacets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/using-eclipse-wtp-with-mavens-eclipseeclipse-goal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servlet Filters mapped to JSPs in Tomcat</title>
		<link>http://www.philihp.com/blog/2011/servlet-filters-mapped-to-jsps-in-tomcat/</link>
		<comments>http://www.philihp.com/blog/2011/servlet-filters-mapped-to-jsps-in-tomcat/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 04:40:00 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[servlet-filter]]></category>
		<category><![CDATA[Struts]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=724</guid>
		<description><![CDATA[Servlet filters were introduced in the Servlet 2.3 spec a long time ago. They&#8217;re basically classes that you can add to any Java webapp that intercept every request and can do anything you can imagine (e.g., compress output, translate, handle authentication, the only limit is yourself). They&#8217;re added into the web.xml file where every webapp starts, [...]]]></description>
			<content:encoded><![CDATA[<p>Servlet filters were introduced in the Servlet 2.3 spec a long time ago. They&#8217;re basically classes that you can add to <em>any</em> Java webapp that intercept every request and can do anything you can imagine (e.g., compress output, translate, handle authentication, <a href="http://www.zombo.com">the only limit is yourself</a>). They&#8217;re added into the web.xml file where <em>every</em> webapp starts, and since every webapp framework builds off of a servlet, they can be used with every webapp regardless of the framework. And they&#8217;re part of the Servlet spec, not the J2EE spec, so you don&#8217;t need a bloated container to use them; you can use them in Tomcat. Basically, what I&#8217;m saying is, they&#8217;re really useful wherever you are, no matter what you&#8217;re doing.</p>
<p>To install a servlet filter in your web.xml, you&#8217;d do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jpa-filter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.philihp.utils.EntityManagerFilter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jpa-filter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>action<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Where the filter will filter any servlet named &#8220;action&#8221; &#8212; which in this case is the name of my Struts 1.3 controller that I had defined earlier. Rather than specify a servlet-name, you&#8217;re allowed to use a url-pattern, but <a href="http://java.sun.com/developer/Books/javaserverpages/servlets_javaserver/servlets_javaserver09.pdf">according to Sun</a>, the url-pattern has to begin with a <code>"/"</code> slash, so <strong>the following does not work</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jpa-filter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/*.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>JSPs are essentially servlets, compiled from JSP code the first time they&#8217;re run. But you don&#8217;t have to define every JSP file in your web.xml file, because they&#8217;re already defined by the container. There&#8217;s a servlet (in tomcat, it&#8217;s the Jasper engine) mapped to <code>/*.jsp</code>. In the Tomcat guts, you can find it at <a href="http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk/conf/web.xml"><code>conf/web.xml</code></a>, which is the basis web.xml file; every webapp deployed in Tomcat is actually extended from this file</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.jasper.servlet.JspServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Since JSPs are essentially running as the servlet name &#8220;jsp&#8221;, you can attach a servlet-filter to them with a filter-mapping similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jpa-filter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/servlet-filters-mapped-to-jsps-in-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the Last Day of a Month in SAS</title>
		<link>http://www.philihp.com/blog/2011/how-to-get-the-last-day-of-a-month-in-sas/</link>
		<comments>http://www.philihp.com/blog/2011/how-to-get-the-last-day-of-a-month-in-sas/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 23:15:39 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[intnx]]></category>
		<category><![CDATA[magic]]></category>
		<category><![CDATA[SAS]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=713</guid>
		<description><![CDATA[SAS has a really neat function called intnx, which will increment a date to the next of an interval. For example, if you have a date (any date. maybe the current date?), you can get the date of the first day of the next month by doing this: data _null_; d = '11JUN2011'd; format d [...]]]></description>
			<content:encoded><![CDATA[<p>SAS has a really neat function called <a href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212700.htm" target="_blank">intnx</a>, which will increment a date to the next of an interval.</p>
<p>For example, if you have a date (any date. maybe the current date?), you can get the date of the first day of the next month by doing this:</p>

<div class="wp_syntax"><div class="code"><pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">data</span> <span style="color: #0000ff;">_null_</span>;
  d = <span style="color: #a020f0;">'11JUN2011'</span>d;
  <span style="color: #0000ff;">format</span> d date9.;
  <span style="color: #0000ff;">put</span> d;
  d = <span style="color: #0000ff;">intnx</span><span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'month'</span>,d,<span style="color: #2e8b57; font-weight: bold;">1</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0000ff;">put</span> d;
<span style="color: #000080; font-weight: bold;">run</span>;</pre></div></div>

<p>Which outputs</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">11JUN2011
01JUL2011</pre></div></div>

<p>But to get the &#8220;Last Day&#8221; of the current month, you have to be clever. The last day of the current month is the day before the first day of the next month. SAS Dates are internally stored as a number of days since some point, so just subtract one from it.</p>

<div class="wp_syntax"><div class="code"><pre class="sas" style="font-family:monospace;"><span style="color: #000080; font-weight: bold;">data</span> <span style="color: #0000ff;">_null_</span>;
  d = <span style="color: #a020f0;">'11JUN2011'</span>d;
  <span style="color: #0000ff;">format</span> d date9.;
  <span style="color: #0000ff;">put</span> d;
  d = <span style="color: #0000ff;">intnx</span><span style="color: #66cc66;">&#40;</span><span style="color: #a020f0;">'month'</span>,d,<span style="color: #2e8b57; font-weight: bold;">1</span><span style="color: #66cc66;">&#41;</span>-<span style="color: #2e8b57; font-weight: bold;">1</span>;
  <span style="color: #0000ff;">put</span> d;
<span style="color: #000080; font-weight: bold;">run</span>;</pre></div></div>

<p>Which outputs</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">11JUN2011
30JUN2011</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/how-to-get-the-last-day-of-a-month-in-sas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>This is how I feel about C</title>
		<link>http://www.philihp.com/blog/2011/this-is-how-i-feel-about-c/</link>
		<comments>http://www.philihp.com/blog/2011/this-is-how-i-feel-about-c/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 03:24:10 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[4chan]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=702</guid>
		<description><![CDATA[I don&#8217;t think C gets enough credit. Sure, C doesn&#8217;t love you. C isn&#8217;t about love&#8211;C is about thrills. C hangs around in the bad part of town. C knows all the gang signs. C has a motorcycle, and wears the leathers everywhere, and never wears a helmet, because that would mess up C&#8217;s punked-out [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>I don&#8217;t think C gets enough credit. Sure, C doesn&#8217;t love you. C isn&#8217;t about love&#8211;C is about thrills. C hangs around in the bad part of town. C knows all the gang signs. C has a motorcycle, and wears the leathers everywhere, and never wears a helmet, because that would mess up C&#8217;s punked-out hair. C likes to give cops the finger and grin and speed away. Mention that you&#8217;d like something, and C will pretend to ignore you; the next day, C will bring you one, no questions asked, and toss it to you with a you-know-you-want-me smirk that makes your heart race. Where did C get it? &#8220;It fell off a truck,&#8221; C says, putting away the boltcutters. You start to feel like C doesn&#8217;t know the meaning of &#8220;private&#8221; or &#8220;protected&#8221;: what C wants, C takes. This excites you. C knows how to get you anything but safety. C will give you anything but commitment</p>
<p>In the end, you&#8217;ll leave C, not because you want something better, but because you can&#8217;t handle the intensity. C says &#8220;I&#8217;m gonna live fast, die young, and leave a good-looking corpse,&#8221; but you know that C can never die, not so long as C is still the fastest thing on the road.</p></blockquote>
<p><a href="http://dis.4chan.org/read/prog/1312655446/4">Anonymous on 4chan</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/this-is-how-i-feel-about-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding Tiles to a Struts 1.3 Project with a Custom Request Processor</title>
		<link>http://www.philihp.com/blog/2011/adding-tiles-to-a-struts-1-3-project-with-a-custom-request-processor/</link>
		<comments>http://www.philihp.com/blog/2011/adding-tiles-to-a-struts-1-3-project-with-a-custom-request-processor/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 08:18:58 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Custom]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Override]]></category>
		<category><![CDATA[RequestProcessor]]></category>
		<category><![CDATA[Struts]]></category>
		<category><![CDATA[Struts 1.3]]></category>
		<category><![CDATA[Tiles]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=695</guid>
		<description><![CDATA[In Struts, if you wanted to do funny shenanigans (e.g. override the Roles checking for authorization, or override the ActionForm population to parse a JSON object rather than standard parameters) with the Struts Controller, up until Struts 1.2, you had to extend the Request Processor and configure the Struts ActionServlet to use it instead. This [...]]]></description>
			<content:encoded><![CDATA[<p>In Struts, if you wanted to do funny shenanigans (e.g. override the Roles checking for authorization, or override the ActionForm population to parse a JSON object rather than standard parameters) with the Struts Controller, up until Struts 1.2, you had to extend the Request Processor and configure the Struts ActionServlet to use it instead. This would get rather complicated when you tried to layer multiple custom controllers together, such as with the Validator and the Tiles plugins.</p>
<p>Struts 1.3 changed this behavior. Rather than all of the heavy lifting being offloaded onto the RequestProcessor object by the ActionServlet, instead there&#8217;s a <a href="http://struts.apache.org/1.x/userGuide/building_controller.html#request_processor">chain of commands</a> executed by a class called &#8220;<a href="http://svn.apache.org/repos/asf/struts/struts1/trunk/core/src/main/java/org/apache/struts/chain/ComposableRequestProcessor.java">ComposableRequestProcessor</a>, and it&#8217;s configured by <a href="http://svn.apache.org/repos/asf/struts/struts1/trunk/core/src/main/resources/org/apache/struts/chain/chain-config.xml">chain-config.xml</a>; which is in the struts-core JAR file. If you want to extend the controller to do out-of-the-ordinary stuff, you&#8217;re supposed to copy this file to somewhere else (like /WEB-inF/custom-chain-config.xml) edit it, and configure the ActionServlet to look at it instead like this</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>action<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.struts.action.ActionServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>config<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/struts-config.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>chainConfig<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/custom-chain-config.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The trouble however, is that the Struts Tiles plugin that shipped with 1.3 didn&#8217;t change from 1.2. It was written to automatically replace the default RequestProcessor and its chain of command. I&#8217;m pretty sure this was supposed to be a convenience, so that to use the Tiles plugin, all you had to do was flip a switch, and it would figure out its own hooks into Struts&#8230; because this is how the Struts Tiles plugin works; it essentially overrides and customizes the RequestProcessor so forwards goto it, rather than to some JSP file or somerthing somewhere. You can see how it&#8217;s doing this overriding by looking at the method <a href="http://svn.apache.org/repos/asf/struts/struts1/trunk/tiles/src/main/java/org/apache/struts/tiles/TilesPlugin.java">TilesPlugin.initRequestProcessorClass</a>; which is actually a little interesting, because it&#8217;s not mucking with any XML. But that&#8217;s all you really have to do, <i>usually</i>.</p>
<p><i>However</i>, and this is why I&#8217;m posting this; if you have a custom chain-config.xml already in place that was based on the chain-config.xml in the struts-core JAR, then your ActionForwards going to Tiles layouts aren&#8217;t going to lookup correctly. For example, when Struts tries to goto the ActionForward &#8220;page.index&#8221;, we get the following exception because normally ActionForwards would goto a page like &#8220;/index.jsp&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">WARNING: Unhandled exception
java.lang.IllegalArgumentException: Path page.index does not start with a &quot;/&quot; character
	at org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:374)
	at org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:196)
	at org.apache.struts.chain.commands.servlet.PerformForward.handleAsForward(PerformForward.java:107)
	at org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:96)
	at org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:54)
	at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
	at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
	at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
	at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
	at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
        ...</pre></div></div>

<p>As far as cryptic errors go, this one is pretty far up there, and unless you actually know how Tiles works, it&#8217;s going to be a huge pain to debug. The remedy is actually to base your chain-config.xml file off of Tiles&#8217; own <a href="http://svn.apache.org/repos/asf/struts/struts1/trunk/tiles/src/main/resources/org/apache/struts/tiles/chain-config.xml">chain-config.xml</a>. And in it you can see how at the end it calls <a href="http://svn.apache.org/repos/asf/struts/struts1/trunk/tiles/src/main/java/org/apache/struts/tiles/commands/TilesPreProcessor.java">TilesPreProcessor</a> right before it performs the forward.</p>
<p>The Tiles documentation indeed says <a href="http://struts.apache.org/1.x/struts-tiles/installation.html">you need to do this</a> &#8212; but hardly anyone ever does, because everything will work unless you customize the request processor; and hardly any books or sites out there will tell you to do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/adding-tiles-to-a-struts-1-3-project-with-a-custom-request-processor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This is how I feel about Perl</title>
		<link>http://www.philihp.com/blog/2011/this-is-how-i-feel-about-perl/</link>
		<comments>http://www.philihp.com/blog/2011/this-is-how-i-feel-about-perl/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 18:37:46 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=692</guid>
		<description><![CDATA[Good code in perl is fine, but there&#8217;s something about bad code in perl that&#8217;s worse than bad code in other languages, something very HP-Lovecraft- mad-servants-of-the-elder-gods-chattering-in-the-extradimensional- insect-language kind of bad that makes my head hurt when I have to read it. Jish Karoshi on comp.lang.ruby]]></description>
			<content:encoded><![CDATA[<blockquote><p>Good code in perl is fine, but there&#8217;s something about bad code in perl<br />
that&#8217;s worse than bad code in other languages, something very HP-Lovecraft-<br />
mad-servants-of-the-elder-gods-chattering-in-the-extradimensional-<br />
insect-language kind of bad that makes my head hurt when I have to read<br />
it.</p></blockquote>
<p><a href="http://groups.google.com/group/comp.lang.ruby/msg/16ced2c242b19d14">Jish Karoshi on comp.lang.ruby</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2011/this-is-how-i-feel-about-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

