Just went through the code. it was not printing the null because it was returning null. If I placed that statement outside if statement in printed me the null value. So this is perfectly working example. Thanks for the reply though
this is not executing anything inside the filter System.out.println() statements
In BeerRequestFilter.java, the method getRemoteUser() returns 'null', if the user is not authenticated. See HttpServletRequest's getRemoterUser() method. Because of this, System.out.println("Just printed the username "+name); is not executed in the following code part.
The System.out.println("This is filter Initialization") in
will be executed during container startup, during initialization phase.