Call URLS using proxy settings
"Asterix45" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <[email protected]> |
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.