- 论坛徽章:
- 0
|
我用英语说说这个问题吧,这个问题国外很多人也在问
Hello to all Ranchers
this is my first post..
now coming to my problem--
I'm trying to make a simple browser for my application and of many options i choose JEditorPane to implement the browser.
When i try to execute the program i get the following error:
java.io.IOException: Authentication failure
at sun.net.www.protocol.http.HttpURLConnect ... onnection.java:649)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:272)
at javax.swing.JEditorPane.getStream(JEditorPane.java:674)
at javax.swing.JEditorPane.setPage(JEditorPane.java:392)
at javax.swing.JEditorPane.setPage(JEditorPane.java:775)
at SwingExamples.EditorPaneFrame.jbInit(EditorPaneFrame.java:41)
at SwingExamples.EditorPaneFrame.<init>(EditorPaneFrame.java:17)
at SwingExamples.EditorPaneFrame.main(EditorPaneFrame.java:50)
I connect to internet through a Web Proxy which needs authentication.
After searching the net and through this forum i found that java.net.Authenticator can be used to provide authentication details.
This is the code i have written:
code:
--------------------------------------------------------------------------------
.............. System.setProperty( "proxySet", "true" ); System.setProperty( "http.proxyHost", "proxyhost" ); System.setProperty( "http.proxyPort", "proxyport" ); Authenticator.setDefault(new SampleAuthenticator()); jEditorPane1.setPage("http://www.google.com");................ class SampleAuthenticator extends Authenticator { public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("myUserName", "myPass".toCharArray() ); } }................
--------------------------------------------------------------------------------
I get the same error even after i use the Authenticator. The JEditorPane establishes a HttpURLConnection by itself, so will it know about the proxy setting and also the authentication detials that i have set?
Any suggestions!!! |
|