You are developing a Java web application, the final application will use some complex security framework (such as Spring Security, formerly Acegi, JSecurity or Shiro, etc.). But in some first milestones, the clients want you to show them the demo of the application, and they want to secure the demo site with a username/password (for things like NDA) and they don't want to wait for later milestones to have that. In this situation, you cannot integrate the above security frameworks because of time constraint, bugs or the complexity of the security frameworks.
A quick and dirty way to do this is using a built-in authentication mechanism of Tomcat (I'm using Tomcat 6.x).
First put those into your web.xml file:



 
  EntireApp
  /*
  GET
  POST
 
 
  client
 


  client



 BASIC
If you use Spring Security, remember to remove Spring Security filter in the web.xml file. Now in your context file (the context.xml file in your META-INF of your web archive or in ther conf/Catalina/localhost/ context file), adding the following:

  
  
   

Finally, edit the tomcat-users.xml (usually located at /conf/tomcat-users.xml) to include all the roles you've specified in the security constraint of you web application, my tomcat-users.xml looks like this (yours may be different):

    
    

Now, every time the clients access the demo site, the browser will pop up a dialog asking for username and password. After successfully authenticated, the clients will use the demo site as normal.
This authentication mechanism is the Basic access authentication. As the title said, this is a quick and dirty way to secure a web application on Tomcat 6.
Hope this saves you some time.
I've just come across a Grails plugin called PrettyTime and I find it's really interesting library. Basically, it's utility library to format Date/Time value in a human-friendly form (eg: "right now", "two days ago", "3 months from now"...), it also supports localization for many languages but Vietnamese. So I decide to write a small resource bundle class for it.
package com.ocpsoft.pretty.time.i18n;

import java.util.ListResourceBundle;

public class Resources_vi extends ListResourceBundle
{
   private static final Object[][] OBJECTS = new Object[][] {
   { "CenturyPattern", "%n %u" },
   { "CenturyFuturePrefix", "" },
   { "CenturyFutureSuffix", " sau" },
   { "CenturyPastPrefix", "cách đây " },
   { "CenturyPastSuffix", "" },
   { "CenturyName", "thế kỷ" },
   { "CenturyPluralName", "thế kỷ" },
   { "DayPattern", "%n %u" },
   { "DayFuturePrefix", "" },
   { "DayFutureSuffix", " sau" },
   { "DayPastPrefix", "cách đây " },
   { "DayPastSuffix", "" },
   { "DayName", "ngày" },
   { "DayPluralName", "ngày" },
   { "DecadePattern", "%n %u" },
   { "DecadeFuturePrefix", "" },
   { "DecadeFutureSuffix", " sau" },
   { "DecadePastPrefix", "cách đây " },
   { "DecadePastSuffix", "" },
   { "DecadeName", "thập kỷ" },
   { "DecadePluralName", "thập kỷ" },
   { "HourPattern", "%n %u" },
   { "HourFuturePrefix", "" },
   { "HourFutureSuffix", " sau" },
   { "HourPastPrefix", "cách đây " },
   { "HourPastSuffix", "" },
   { "HourName", "giờ" },
   { "HourPluralName", "giờ" },
   { "JustNowPattern", "%u" },
   { "JustNowFuturePrefix", "" },
   { "JustNowFutureSuffix", " khắc sau" },
   { "JustNowPastPrefix", "cách đây " },
   { "JustNowPastSuffix", " khắc" },
   { "JustNowName", "" },
   { "JustNowPluralName", "" },
   { "MillenniumPattern", "%n %u" },
   { "MillenniumFuturePrefix", "" },
   { "MillenniumFutureSuffix", " sau" },
   { "MillenniumPastPrefix", "cách đây " },
   { "MillenniumPastSuffix", "" },
   { "MillenniumName", "thiên niên kỷ" },
   { "MillenniumPluralName", "thiên niên kỷ" },
   { "MillisecondPattern", "%n %u" },
   { "MillisecondFuturePrefix", "" },
   { "MillisecondFutureSuffix", " sau" },
   { "MillisecondPastPrefix", "cách đây " },
   { "MillisecondPastSuffix", "" },
   { "MillisecondName", "mili giây" },
   { "MillisecondPluralName", "mili giây" },
   { "MinutePattern", "%n %u" },
   { "MinuteFuturePrefix", "" },
   { "MinuteFutureSuffix", " sau" },
   { "MinutePastPrefix", "cách đây " },
   { "MinutePastSuffix", "" },
   { "MinuteName", "phút" },
   { "MinutePluralName", "phút" },
   { "MonthPattern", "%n %u" },
   { "MonthFuturePrefix", "" },
   { "MonthFutureSuffix", " sau" },
   { "MonthPastPrefix", "cách đây " },
   { "MonthPastSuffix", "" },
   { "MonthName", "tháng" },
   { "MonthPluralName", "tháng" },
   { "SecondPattern", "%n %u" },
   { "SecondFuturePrefix", "" },
   { "SecondFutureSuffix", " sau" },
   { "SecondPastPrefix", "cách đây " },
   { "SecondPastSuffix", "" },
   { "SecondName", "giây" },
   { "SecondPluralName", "giây" },
   { "WeekPattern", "%n %u" },
   { "WeekFuturePrefix", "" },
   { "WeekFutureSuffix", " sau" },
   { "WeekPastPrefix", "cách đây " },
   { "WeekPastSuffix", "" },
   { "WeekName", "tuần" },
   { "WeekPluralName", "tuần" },
   { "YearPattern", "%n %u" },
   { "YearFuturePrefix", "" },
   { "YearFutureSuffix", " sau" },
   { "YearPastPrefix", "cách đay " },
   { "YearPastSuffix", "" },
   { "YearName", "năm" },
   { "YearPluralName", "năm" },
   { "AbstractTimeUnitPattern", "" },
   { "AbstractTimeUnitFuturePrefix", "" },
   { "AbstractTimeUnitFutureSuffix", "" },
   { "AbstractTimeUnitPastPrefix", "" },
   { "AbstractTimeUnitPastSuffix", "" },
   { "AbstractTimeUnitName", "" },
   { "AbstractTimeUnitPluralName", "" } };

   @Override
   public Object[][] getContents()
   {
       return OBJECTS;
   }
}

Hopefully they will integrate this snippet into the next release of PrettyTime.
A couple months ago, I moved my blog from Blogger to Wordpress, that's because Wordpress offers some nice themes. Recently, I've bought a new domain (my first domain actually) and I want to use that domain for my blog but it costs me 10$/year to use custom domain in Wordpress! Searching around and I found that Blogger let you use your custom domain for free with hassle-free setup. Horay!
Then I moved back to Blogger, but the problem arises, the ugly theme! I think it's the right time for me to learn CSS and start hacking Blogger API. And after 2 weeks of hard working, I've finished my custom theme for Blogger based on Natural Power theme for Wordpress.
I'm quite happy with the result I've got so far. Not too bad for a CSS newbie.
From the normal user perspective, Wordpress provides many useful functionality out of the box, but if flexibility is your top priority, Blogger is your best choice so far.

Some thoughts about Grails

I've just finished my first Grails project. To be honest, it's a quite good mind refreshment for me as a Java developer. Grails simplify alot of complex stuff of Java ecosystems like IoC(Spring), ORM(Hibernate), XML configuration with convention over configuration. It takes you less than 10 minutes to create a full working web application with Spring Security for authentication and authorization, Quartz for job scheduling and Hibernate for data persistence when you're familiar with it. Here are some Pros and Cons:
Pros:
  • Almost "zero learning effort" for Java developers (although it almost took me a week to get productive with it)
  • No XML configuration
  • GORM is much easier to work with comparing to Hibernate (both XML-based and annotation-based), dynamic methods for domain class is definitely a good selling point for me here. It saves me tons of DAO code.
  • Lots of plugins to extend Grails functionalities
Cons:
  • Grails heavily uses convention-over-configuration but the documentation about conventions is not enough. Sometimes it get frustrated when you reading someone's code without knowing the convention his/her using.
  • Bugs. Lots of it, just navigate to JIRA of Grails and you will know what I mean :)
  • Lacking of good IDE support. First I've tried Spring STS, then NetBeans, then IntelliJ IDEA Ultimate (free trial) and finally finishing my first Grails project in Gedit!
Grails is a great framework and I'm still learning it.