Execute code after HTTP response is sent
-
05-10-2020 - |
Question
In a Java servlet based web application, is there any way to execute some code after and depending on the HttpServletResponse
that has been sent to the client?
Solution
You can:
- make a
Filter
that has code after thechain.doFilter(request, response)
method - make a filter that wraps the
HttpServletResponse
in a custom response object which handles whatever operations you like - in this case - replacing theOutputStream
with one that logs the desired information
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow