How should I resolve java.lang.IllegalArgumentException: protocol = https host = null Exception? -
I am working on an SSL client server program and I have to use the following method again.
Private Boolean Post Message (String Message) {try {string serverURLS = getRecipientURL (message); ServerURLS = "https: \\\\ abc.my.domain.com.6855 \" update "; if (serverURLS! = Tap) {serverURL = new URL (serverURLS);} HttpsURLConnection conn = (HttpsURLConnection) serverURL.openConnection ( ); Conn.setHostnameVerifier (New hostname description) {Public Boolean Verify (string AGR2, SSL Senson AG1) {Return true;}}; conn.setDoOutput (right); OutputStream OS = conn.getOutputStream (); OutputStream Vibrator wr = new output speed water (OS); wr.write (message); wr.flush (); if (conn.getResponseCode ()! = HttpsURLConnection.HTTP_OK) false return; and come back true;}< / Pre>here URL is started
private url serverURL = null;When I try to execute this method, I get an exception on the line
OutputStream OS = conn.getOutputStream ();
is an exception
java.lang.IllegalArgumentException: Protocol = https host = nullWhat's the reason?
URLs do not use forward slash (/), backward sections (in the form of windows). Try:
serverURLS = "https://abc.my.domain.com. 6855 / update"; The reason for getting the error is that the URL can not parse the host part of the string and therefore, host is null .
Comments
Post a Comment