"If the port is not specified in URL, the default port for the protocol is used instead.
the default port for http is 80."
Ulf Dittmer wrote:.................... the -1 value that causes the default port to be used.
"If the port is not specified in URL, the default port for the protocol is used instead.
the default port for http is 80."
naveen yadav wrote:It means that port 80(default) is used. but as the docs for getPort() doesn't says anything about that. So getPort() does not return that port(80).
And since i have not set any port in the URL ,that's why getPort() returns -1.
Is that a whole story ?
Paul Clapham wrote: You are just making the incorrect assumption that the getPort() method tells you which port will be used. It doesn't do that
public int getPort() Gets the port number of this URL.
Returns:the port number, or -1 if the port is not set
Paul Clapham wrote:................. You are just making the incorrect assumption that the getPort() method tells you which port will be used. It doesn't do that, and its documentation doesn't say it will do that.
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|