• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to connect a url(java.net.url) when usin a proxy setting

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to write a programme in Java which can connect a website and return data from the website( like its opening page, and its source eg. HTML code or Java script code of that site )...
i can use:
java.net.url myUrl = new URL("http://www.mySite.com");
But how to connect this site if i am using proxy setting.And again how to show the content of this site ?
Thanks in advance
Regards
Aminur

------------------
Regards
Aminur
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the http.proxyHost and http.proxyPort system properties (either set them programmatically using System.setProperty, or using the -D flag on the java command line).
If you need to connect to secure sites using JSSE, you may also want to set https.proxyHost and https.proxyPort.
If you need authentication, check out java.net.Authenticator. I don't have first hand experience using this class, but it looks like you have to create your own Authenticator subclass that serves up username and password, and register it using Authenticator.setDefault().
I do agree that the documentation for these properties is extraordinarily well hidden.
- Peter

[This message has been edited by Peter den Haan (edited September 27, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic