i want to establish a https connection for which i will provide a hostname portno username password etc.
most of the online code snippets are mostly using SSl or TSL inorder to establish a connection if not using a url and establishing the connection by appending the encrypted username and password with it to establish a connection.
i have a scenario where i use a hostname portno(optional) username password and to establish the connection. can any one guide me how to do this.
Have you tried new URLConnection("https://www.server.com:1234")? It'll probably work out of the box. Passing the username/password has nothing to do with HTTP vs. HTTPS, so you need to do that independently of making the connection.
will answer my problem?
but if you have asked me whether https connection worked using the url then my answer is yes.
correct me if i am wrong in understanding what you have asked and i guess i made my requirement clear, please guide me.
Rob Prime wrote: a URL and host name do not need to be mutually exclusive. http://www.javaranch.com/ is a URL that has a host name; http://127.0.0.1/ is a URL that has an IP address.
upto my knowledge the IP-address for machine in order to make it more simple to use undergoes DNS configuration which will get www.somename.com, correct me if i am wrong.
so here can say from your explanation that i can use the machine name that i am using as the hostname for the sake of the connection(secure)?
It's the other way around - www.somename.com will be translated into an IP address. So if you use a host name in the URL, this is somewhere in the background (probably even outside your Java program) translated into an IP address, and a request is made to this IP address on the port you specified with the HTTPS protocol. So what makes your connection secure is not the host name, IP address or port, but the protocol.