For Programmers: Free Programming Magazines  


Home > Archive > Java Help > April 2004 > Help clearing http.proxyHost system propery









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help clearing http.proxyHost system propery
George Orwell

2004-04-25, 11:45 am


I have a problem clearing the http.proxyHost system propery in my app.

If the propery is not already set via the

-Dhttp.proxyHost=

option when the app is launched, then the program displays

http.proxyHost=null

when

System.out.println("http.proxyHost="+System.getProperty("http.proxyHost"))

is executed as it should since the property has not been set.

I have no problem setting the property to some value like 10.12.15.0 using

System.setProperty("http.proxyHost","10.12.15.0")

or

String proxy = "10.12.15.0"
System.setProperty("http.proxyHost",proxy)

But if I want to clear the value,

System.setProperty("http.proxyHost",null)

or

String proxy = null
System.setProperty("http.proxyHost",proxy)

doesnt seem to work.

I end up with a NullPointerExcption at java.util.Hashtable.put

Does anyone have a solution for this? Thanks in advance.

Raymond DeCampo

2004-04-25, 4:38 pm

George Orwell wrote:
>
> But if I want to clear the value,
>
> System.setProperty("http.proxyHost",null)
>
> or
>
> String proxy = null
> System.setProperty("http.proxyHost",proxy)
>
> doesnt seem to work.
>
> I end up with a NullPointerExcption at java.util.Hashtable.put
>
> Does anyone have a solution for this? Thanks in advance.
>


George,

Use System.getProperties() to get the Properties object itself. Then
you can clear the value directly using the Properties API. It may be
necessary to call System.setProperties() afterward, as the documentation
is not clear whether the System.getProperties() method returns the
actual system Properties object or a copy.

Ray
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com