I'm working with an API that is not well documented and I am trying to save the requests made to the server so I can better understand the inner workings.
Some preliminary research yielded two possible solutions:
A) Filters
B) Request Dumper Valve
Here are some of the areas where I found helpful advice that I didn't understand how to use:
Logging Payload of POSTs to Tomcat
https://coderanch.com/t/484631/application-servers/configure-Tomcat-log-POST-data
My problem is not with the solutions that were provided in the above links, it's that I don't understand how to utilize them in Tomcat.
For example, in the first link the OP posts:
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
LOG.debug("payload: " + requestWrapper.getRequestBody());
and web.xml:
<filter>
<filter-name>PayloadLoggingFilter</filter-name>
<filter-class>com.host.PayloadLoggingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PayloadLoggingFilter</filter-name>
<url-pattern>/resources/*</url-pattern>
</filter-mapping>
Which is great! Except that if I add the code above into my web.xml my localhost TomCat will only return 404, and I have no idea where I should put the Java code as it can't compile on its' own and definitely requires some dependencies.
Any help is appreciated.