JSTL String test oddity

I’ve come across this multiple times, and for some reason this always catches me out. You’d think being that EL has ‘eq’ and ‘ne’ operators that work with Strings that this should work:

<c:if test="${hello.name ne ''}">
    Hello <c:out value="${hello.name}"/>
</c:if>

This seems to make sense that it would do what you think it should do, but no, it always returns true. The code you’re looking for is using EL operator ’empty’:

<c:if test="${!empty hello.name}">
    Hello <c:out value="${hello.name}"/>
</c:if>

Git notes

Typical add/commit/push workflow:

#add local change ready to commit
git add .

#git commit changes to repo
git commit -m "commit message"

#push to remote repo
git push [optional remote repo name here, eg origin, etc]

Find changes committed locally compared with remote repo, i.e. to find what you’ve committed locally but not yet pushed:

git diff --stat [remote repo name]

List associated remote repos and their locations:

git remote -v

Add a new remote repo to an existing local app/repo:

git remote add remotename remote_git_repo_url

Setting JAVA_HOME on Mac OS X

Some time ago I had set JAVA_HOME in my .profile on Mac OS X to the following:

JAVA_HOME=/Library/Java/Home; export JAVA_HOME

To some extent this works, but it doesn’t apparently pick up your preferred JDK version that you can set via the Java Preferences app in /Applications/Utilities (you set your preferred version by dragging your choice to the top of the list).

To set JAVA_HOME to be set to your preferred version, use this instead:

JAVA_HOME=`/usr/libexec/java_home`; export JAVA_HOME

This post here talks about the first approach, but there’s a comment in response to the post that points out the second point.