public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
// do something before the rest of the application
chain.doFilter(request, response); // invoke the rest of the application
// do something after the rest of the application
}
I was under the impression that code before chain.doFilter will be executed before going to the controller and after the chain.doFilter Controller will be called. I added a Sysout after chain.doFilter and added Sysout in Controller. To my surprise, Sysout after chain.doFilter printed first
What is the flow of execution?
Why request body is not printed before chain.doFilter(request, response); in OncePerRequestFilter. I was getting blank request body when I try to print before chain.doFilter. But it is working as expected when I print it after chain.doFilter