Re: Call URLS using proxy settings

Peter Hansson <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <CAC55jYMuo+BO2UKvUqgLs3NEnM-W1SCDSzxuntg8QJ7fyqOdJg@mail.gmail.com>
The ProxySelector that the NB Platform installs (which is what you can
influence via Tools --> Options --> General) is indeed global. It *should*
be used by any URLConnection.

One suggestion would be to set
sun.net.www.protocol.http.HttpURLConnection.level=FINEST on your
application startup as that will give you some additional logging as to
what is going on, in particular it will tell you what proxy is being used.

On Sat, Dec 5, 2015 at 12:48 PM, Asterix45 <[email protected]>
wrote:

> Hi all,
>
> I'm new to the forum and new on the NetBeans Platform, this is my first
> project with this.
>
> I've created my application with some modules, also I've personalized the
> menu toolbar showing only the General Setting label and I'd like to use the
> proxy setting inside.
>
> Starting my application I can navigate to this option panel and correctly
> change the proxy settings. Using the test button I have correct messages
> according to the proxy settings.
>
> Now I have created a new setting panel, with some preferences for my
> application. This application calls urls and should use the plain text
> returned (a sort of web  services..).
>
> In my code I use this to calls web links:
>
>
> Code:
>
> URL url = new URL("http://www.google.it");
> URLConnection con= url.openConnection();
> InputStream is =con.getInputStream();
>
> BufferedReader br = new BufferedReader(new InputStreamReader(is));
>
> String line = null;
>
> // read each line and write to System.out
> while ((line = br.readLine()) != null) {
>       System.out.println(line);
> }
>
>
>
>
> This code correctly retrieves the plain text from the url but it doesn't
> care about proxy settings, so it  works with no proxy, also if I change the
> proxy settings in a wrong way.
>
> How I should modify my code in order to use proxy settings? Do you know
> where to find a good example for this?
> I've seen tutorial about web services request and feed reader but they use
> other classes that I don't need now for this project and I would use a
> basic approach only using Platform utility.
>
> Thanks in advance for any responses.
>
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.