I have a third-party servlet inside the JAR that I cannot change. I expanded this servlet and used it in normal mode, since the servlet should be used, the client side makes an HTTP request that calls my servlet.
But now the client needs an automatic service, that is, I will need to make some requests to this third-party servlet from the same webapp where the servlet is located.
I looked at the third-party servlet code, but I did not find a place to bypass the servlet, because the HttpServletRequest and HttpServletResponse objects are passed from method to method ... Basically, it seems that I will need to re-implement all third-party codes.
The solutions that I found but do not satisfy me:
Servlet call from URL with HttpURLConnection:. In my common sense, saying that calling a third-party servlet from a URL is not the best way to go, except for the added overhead, I don’t want to disclose a third-party servlet. Calling my servlet from a URL also creates problems with sessions and other things.
Call doGet directly:. This seems to be out of the question because the implementation of HttpServletRequest and the implementation of HttpServletResponse.
Use jMock or something like that: I haven’t researched this solution, but it’s not mistaken to use the test library in a real environment.
Anyone have an idea how to interact with this third party servlet?
EDIT:
Since my English is not very good, and it’s hard for me to explain myself, here is a schematic attempt to explain better

EDIT2: after a third-party meeting, they suggest isolating the methods I need to avoid calling the servlet. If you don't have the same luck, I checked the answers of both gigadot and BalusC.