Tuesday, November 19, 2013

Good Bye Apache Tiles

Dear Tiles, I've always questioned your wisdom, now I'm dropping you.
This will be my last project ever to use Apache Tiles again. Apache Titles suffers from out dated documentation, unjustified configuration, low activity and is an overall inferior templating solution.

I now use the solution discussed in this stackoverflow question:
http://stackoverflow.com/questions/1296235/jsp-tricks-to-make-templating-easier

As well as a solution put forward by KwonNam on github:
https://github.com/kwon37xi/jsp-template-inheritance



Wednesday, February 29, 2012

Maven Best Practices

Creating a local maven repository in your company

Try  Artifactory.


It is also useful (if there are more than 1-2 developers working together) to set up an internal repository (likeArtifactory) and use that internally. It makes it much easier to deal with libraries that are not in the public repos (just add it to your internal repo!) and you can also use build tools to push builds of your own code there so other can use the modules without checking out the code (useful in larger projects)

Dividing your java maven project into sub-modules and sub-projects using m2eclipse

Tuesday, February 28, 2012

Checkout subdirectory in git for previous revision

From: http://stackoverflow.com/questions/5859943/subdirectories-in-checked-out-directory-of-a-previous-revision-not-disappearing

To checkout a sub-folder from a previous revision, what you do is three commands:

git reset <hash> thing/
git checkout <hash> thing/
git clean -fd thing/

To revert back to the HEAD state:

git reset HEAD thing/
git checkout HEAD thing/
git clean -fd thing/

I didn't try the three HEAD commands above. But should work.






Handling null values in freemarker using if condition

From: http://stackoverflow.com/questions/306732/how-to-check-if-a-variable-exists-in-a-freemarker-template

Two solutions:

First Solution:
Example 1:
<#if userName??>
   Hi ${userName}, How are you?
</#if>
Example 2:
<#if router.cableFacility.direction??>
   Hi ${router.cableFacility.direction}, How are you?</#if>
Second Solution:
Hi ${userName!}, How are you?
the default operator also supports a default value, such as:
Hi ${userName!"John Doe"}, How are you?

Tuesday, February 21, 2012

Executing a command using another user on linux

If the user has no shell associated with it (ie. passwd indicates a nologin at the end of

su -s /bin/bash -c "command to run" apache

If user has a login shell then there is no need for -s /bin/bash