java调用外部servlet_如何从java调用servlet

我在JAR中有一个我无法改变的第三方servlet.我已经扩展了该servlet并且正常使用它,因为应该使用servlet,客户端发出一个调用我的servlet的HTTP请求.

但是现在客户端想要一个自动服务,也就是说,我需要从servlet所在的同一个webapp对该第三方servlet做一些请求.

我查看了第三方servlet代码,但我没有找到绕过servlet的地方因为HttpServletRequest和HttpServletResponse对象从方法传递给方法……基本上我似乎需要重新实现所有第三方派对代码.

Solutions I found but do not satisfy me:

Call servlet from URL with HttpURLConnection: My common sense says that calling the third party servlet from a url is not the best way to

go, besides the overhead added, I don’t want to expose the third party

servlet. Calling my servlet from a url also brings problems with

sessions and other things.

Call the doGet directly: This seems to be out of the question because there is no implementation for the HttpServletRequest and

HttpServletResponse.

Use jMock or something like that: Didn’t explore this solution yet, but it seams wrong to use a test-driven library in the real

environment.

任何人都知道如何与第三方servlet交互?

编辑:

由于我的英语不是很好,我发现自己很难解释,这里有一个原理图,试图更好地解释

编辑2:在与第三方制造商会面后,他们提出隔离我需要避免调用servlet的方法.如果你没有同样的运气,我确实检查了gigadot和BalusC的答案.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值