cancel
Showing results for 
Search instead for 
Did you mean: 

Proxy-Configuration for Java applications

Former Member
0 Kudos

Hi guys

I'm connecting to an url through a proxy within a servlet. For this purpose I entered the following coding

System.setProperty("http.proxyHost", "proxyserver.com");

System.setPropery("http.proxyPort", "8080");

This works fine so far. However I would like to specify these settings on a administrative level. Thus I entered the following configuration parameters in the configtool->instance->server:

-Dhttp.setProxy=true

-Dhttp.proxyHost=proxyserver.com

-Dhttp.proxyPort=8080

-Dhttp.nonProxyHosts="localhost|*.company.com"

However they don't work .. allthough they're properly written into the instance.properties file after restart.

The test System.getProperties("http.proxyHost") just returns null.

Do you have an idea why this doesn't work?

Cheers

Stephan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mirko,

unfortunately, this servlet runs besides the portal on the WAS. Thus the proxy settings of the portal won't work for this app.

You're right: I should have selected a different forum ... hope find a solution anyway.

Thanks a lot and regards

Stephan

Former Member
0 Kudos

Hi Stephan,

OK, no reason for me to give up

In my opinion http proxy configuration is a big mess.

Possibly your setting are overwritten by an internal service on your WAS and therefor can not survive until you need them.

Because of that I would recommend using the Jakarta Commons HttpClient in your servlet:

http://jakarta.apache.org/commons/httpclient/

It has a good documentation and gives you full control over HTTP including proxy settings.

Best regards

Mirko

Former Member
0 Kudos

Hi Mirko,

well according to my understanding this approach doesn't provent creating a new configuration file storing the proxy settings, since the documented way to read System properties won't work either, right?

Since there will be different developing streams at this customer side which need a proxy additional configuration files will lead to inconsistency and a big administrative overhead...

Cheers

Stephan

detlev_beutner
Active Contributor
0 Kudos

Hi Stephan, hi Mirko,

Even if your app is a servlet app beneath the portal, if the portal is running, the service gets started with the portal and sets the system parameters itself from it's configuration (if there are any). See sourcecode of com.sapportals.portal.ivs.proxy.ProxyServerService (you'll have to decompile).

So, you can try to use this EP service as your central configuration point.

Anyhow, this does not explain why the settings -D... are not retrievable (for the EP service does not override them if no proxy is set within EP config; this at least holds for EP6 SP2 P32). I just tested it within my environment - setting -Dhttp.proxyHost=my.proxy.com has been retrievable, no problem at all.

Some additional remark: "http.setProxy=true" must read "http.proxySet=true".

Hope it helps

Detlev

PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

Former Member
0 Kudos

Hi Stephan,

as you are posting your question in an EP forum I guess your servlet is running as an iView. If this is the case you can configure a HTTP-Proxy in the EP. This is pretty well documented under:

http://help.sap.com/saphelp_nw04/helpdata/en/33/8abf9e0ce011d7b84900047582c9f7/content.htm

Best Regards

Mirko