Using the API provided by tomcat, you can get an HttpServletRequest object
HttpServletRequest request = (HttpServletRequest)org.apache.catalina.core.ApplicationFilterChain.getLastServicedRequest();
This will get the last request sent to the servlet for servicing from the current thread.
This work is only performed in Tomcats "Strict Servlet Compliance" mode. To enable it, add the following JVM parameter:
org.apache.catalina.STRICT_SERVLET_COMPLIANCE=true
swapy
source share