You already consumed all data sent with the request, so there's nothing left for the super.doPost(...)
method!
You could instead pass a HttpServletRequestWrapper
to super.doPost(...)
. It should wrap the original request but returns a different InputStream
that is backed by the bytes array you've already read in this method. Also note that it will be necessary to also wrap the reader that can be obtained from the request (HttpServletRequest#getReader()
).
See also How to log response content from a java web server, there you can find a complete code sample about the opposite side of logging. I think it can easily be adopted to what you need.