This is a revised version of my previous blog
I have converted the code to a simple dynamic web project since many are not familiar with maven and could not access the sample code.
The link to the latest code is attached here