I need to log the request and response what user has requested. Currently am using filters and logging the request in doFilter() method. But if i forward the request from one servlet to another servlet it is logging twice. I need to find out the forwarded request and skip log for that. Could anyone suggest how to find the forwarded request.
1 Answer
Use request.getDispatcherType(). In case of direct request it's request.getDispatcherType().name() be REQUEST, in case of forward - FORWARD