https - Using java class HttpsURLConnection -
i have small piece of code impements http-client, i.e. posts request , works re response. long http concenerned everthing work well. reason have support https too. here briefly in order connection opened:
url url = new url(serveraddress); httpsurlconnection httpsconn = (httpsurlconnection) url.openconnection();
this fails, stating:
sun.net.www.protocol.https.httpsurlconnectionimpl cannot cast com.sun.net.ssl.httpsurlconnection
i guess kinda trivial, don't i'm doing wrong in one... googled it, , code looks right - not?
any ideas appreciated!
just keep java.net.urlconnection
or cast java.net.httpurlconnection
instead. both offers methods desired task good.
a side remark unrelated technical problem: should never explicitly import/use sun java se implementation specific classes in code. undocumented classes , subject changes may cause code break when upgrade jvm. on other hand, code may break when run @ different brand jvm.
update: since seem accidently have imported it, go window > preferences > java > appearance > type filters , add com.sun.*
, sun.*
list. way won't ever import them accidently. see screenshot.
Comments
Post a Comment