I have a WEB application deployed to Tomcat. I would like to intercept all incoming requests - receive or send and complete some task. I want to intercept calls from a servlet, from JSP pages, etc. So I created one web.xml file that looks like this one -
<servlet>
<description></description>
<display-name>Transformer</display-name>
<servlet-name>Transformer</servlet-name>
<servlet-class>com.test.Transformer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Transformer</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
As we can see, any request will go to this controller servlet called Transformer. Now this servlet usually tries to convert one request from A to B. The problem I am facing is what I get in the loop. I just want to convert the request for url / test.jsp to /abc/test.jsp, but the second request /abc/test.jsp also gets into the Transformer servlet, and as a result, it does not work properly. I think I can use Filter, but I have too many servlets and JSP pages in the application to put the filter everywhere.
source
share