I have built a service to extract various details like header, request uri, status code etc from an HttpServletRequest and HttpServletResponse object. I want to extract this information and store it in mongo. Now, I have other services with a servlet filter in them. What I want to do is, whenever a request comes in, I want it to get executed also and simultaneously forward the HttpServletRequest & HttpServletResponse object to the first service so that it can extract data from it and store it somewhere. Any idea how this can be done? I want the first service to be generic, it will have an API that will accept request and response objects of various other services and store its data in mongo. The extraction of fields like request uri, status code etc needs to happen in the generic service only
Asked
Active
Viewed 225 times
-1
-
Try using Filter. In the filter, you can extract request info and then call `doFilter(req, resp)`. – Md Zahid Raza Jul 13 '21 at 19:20
2 Answers
0
As per my understanding of this question, you can call that service passing the same request and response object and get the data from that. If you give the code snippet it will be easy to describe.
Hope this answer will help you.

Kaushik Shaw
- 41
- 3
-
how do I call that service and pass the HttpServletRequest and HttpServletResponse objects to it? RestTemplate.exchange is not working – Aditya Joshi Jul 14 '21 at 07:05