如何拦截tomcat上的传出请求?
在 tomcat 上运行两个应用程序:
- Application1 (JSP)
- Application2 (Webservices)
我想设置从 Application1 发出的请求参数(用户对象,包含有关当前用户的信息),当此请求到达 Application2 时,我想检索参数并更改Application2中的一些本地配置。
我知道我可以使用 Filter 来过滤 Application2 中的传入请求,但是如何过滤 Application1 中的传出请求呢?
Got two applications running on tomcat:
- Application1 (JSP)
- Application2 (Webservices)
I want to set request parameter (User object, with information about current user) that is going out of the Application1 and when this request gets to Application2 I want to retrieve the parameter and change some local configurations in Application2.
I know I can filter the incoming request in Application2 by using Filter, but how can I filter the outgoing request in Application1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您说“传出请求”时,我将其理解为“响应”。我建议您还使用 Servlet Filter 在 Application1 经过正常的过滤器/处理链后对其进行更改。
即:
我不明白如何使用 修改请求/响应参数阿帕奇阀门。
When you say "outgoing request" I understand this to be the 'Response'. I would suggest you also use a Servlet Filter to make your change in Application1 after it has gone through the normal filter/processing chain.
i.e.:
I don't see how you could modify the request / response parameters with Apache Valve.
我能够通过实现 SOAPHandler 类来实现我的目标。我能够拦截 SOAP 消息,添加标头参数,当 SOAP 消息到达 Application2 时,我提取了这些标头信息,实现了相同的 SOAPHandler。
I was able to accomplish my goal by implement a SOAPHandler class. I was able to intercept the SOAP message, add headers parameters and when that SOAP message arrived at Application2 I extracted those headers information implement the same SOAPHandler.