To block user during maintenance mode you need to switch a user from normal mode to maintenance mode. A way to intercept all incoming requests and redirect them to the maintenance mode page, is to add a Servlet Filter to your web application. Inside the Servlet Filter you need to check whether the filter is in normal operation mode, or maintenance mode.
If the filter is in normal operation mode, the request is passed on to the web application as normal. If the filter is in maintenance mode the request should be passed on to a maintenance message page instead.
The following link can help you in configuring filter in maintenance mode :
http://tutorials.jenkov.com/java-web-apps/web-app-maintenance.html