Tomcat和代理设置 [英] Tomcat and proxy settings

查看:299
本文介绍了Tomcat和代理设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在tomcat7上运行了一个servlet,它向第三方网站发出web服务调用。
来自windows机器的调用工作正常但是从tomcat运行时它失败了。
Wont Tomcat会不会自动使用Windows的代理设置?
我添加了

There is a servlet running on tomcat7 and it makes a webservice call to a third party website. The call works fine from the windows machine but when run from tomcat it fails. Wont Tomcat automatically use the Windows' proxy settings? I added

set JAVA_OPTS=%JAVA_OPTS% "-Dhttp.proxySet=true"
set JAVA_OPTS=%JAVA_OPTS% "-Dhttp.proxyHost=IP"
set JAVA_OPTS=%JAVA_OPTS% "-Dhttp.proxyPort=8080"

到CATALINA.BAT

to CATALINA.BAT and

http.proxyHost=IP
http.proxyPort=8080

到catalina.properties
但仍然没有变化。
我们如何设置Tomcat使用windows的代理设置?有没有办法检查tomcat是否正在获取指定的代理设置?

to catalina.properties But still there is no change. How do we set Tomcat to use the proxy settings of windows and is there a way to check if tomcat is picking up the proxy settings specified?

推荐答案

不,Tomcat不会自动使用系统代理设置。

No, Tomcat won't automatically use the system proxy settings.

我建议您查看 java.net.Proxy 。这允许您在运行时动态指定代理。系统属性可以工作,但它们只读一次,如果Tomcat在设置它们之前已经使用 HttpURLConnection 用于它自己的目的,那就是它的设置:没有效果。

I suggest you look into the facilities provided by java.net.Proxy. This allows you to dynamically specifiy a proxy at runtime. The system properties work but they are only read once, and if Tomcat has already used an HttpURLConnection for its own purposes prior to you setting them that's the end of that: the setting has no effect.

这篇关于Tomcat和代理设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆