I’m having problems understanding a line of code and the Liferay API documentation doesn’t give details. The lines is this one:
StringBuilder url = new StringBuilder(PortalUtil.getPortalURL(cp.getVirtualHost(), PortalUtil.getPortalPort(), false));
I know the first parameter gets its value from the virtual host in the main configuration, and the third one if set to true gets you a https URL, but i don’t know from where its getting the port, also when the port is 80 it doesn’t get added to the url.
What i need is that the port doesn’t show even if its different from 80, any ideas?
As far as I understand this is common line of code to determine URL of Liferay Portal in a portlet or a hook plugin.
I think, the port is simply determined from the current request.
The reason why port 80 isn’t showing is because it’s standart HTTP port and it will be used by default. So you can’t hide port from URL if it’s different from 80 (or 443 for secure connection).