• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on sun.net.www.http.HttpClient class whether it supports https protocol

 
rajareddya reddy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

My requirement is to call HTTPS URL through java code(through HTTP URL call).
for that I am using sun.net.www.http.HttpClient class.

I need to know whether sun.net.www.http.HttpClient class supports only HTTP or it supports HTTPS also
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not use any of the sun.* classes directly. What's wrong with javax.net.ssl.HttpsURLConnection?
 
rajareddya reddy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting connection refused error when i am accessing HTTPS URL through java code


TWKOnlineSubmit | submitWithResponse | [b]SocketException : java.net.ConnectException: Connection refused
java.net.ConnectException: Connection refused
at sun.reflect.GeneratedConstructorAccessor196.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)
at com.crimsonlogic.thb.twkonline.TWKOnlineSubmit.submitWithResponse(TWKOnlineSubmit.java:350)
at com.crimsonlogic.thb.test.servlet.TWKOnlineSubmitServlet.submit(TWKOnlineSubmitServlet.java:128)
at com.crimsonlogic.thb.test.servlet.TWKOnlineSubmitServlet.doPost(TWKOnlineSubmitServlet.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3717)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
[/b]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So - is the target host accessible from whichever machine this code runs on through whichever port you're using?
 
rajareddya reddy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, target is accessible from the machine where application is running.
Facing the problem while connecting URL through java code
 
rajareddya reddy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

One last question.

I want to know whether sun.net.www.http.HttpClient api supports HTTPS

I am using jdk 1.6 version
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The better question is: what do you hope to achieve by using that class that you can't achieve by using a class that is part of the Java API?
 
rajareddya reddy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply

Ours is maintenance project.Code is already developed.in that somebody already coded that sun.net.www.protocol.http.httpurlconnection used for connecting HTTP URL. But recently our requirement changed.We need to connect to HTTPS URL with sun.net.www.protocol.http.httpurlconnection without changing this API.

Now when we are connecting HTTPS URL, we are getting connection reused error.

Is it a server problem or code problem.

If it is code problem I want to know whether sun.net.www.protocol.http.httpurlconnection api supports HTTPS URL call


 
Paul Clapham
Sheriff
Posts: 21565
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me that this would be a good time to fix the programming error -- by which I mean the use of a "sun.*" class, which is universally dis-recommended.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:It seems to me that this would be a good time to fix the programming error -- by which I mean the use of a "sun.*" class, which is universally dis-recommended.


This view has also been expressed forcefully in the Oracle Java forums but the OP is not listening.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic