Is it possible to get the Portal base URL (like http://www.thisismyportal.com) from a Portlet using Portlet 2.0 API?
Right now I'm planning to manually build it concatenating PorletRequest.getServerName()
, PortletRequest.getServerPort()
and PortletRequest.getContextPath()
; but it seems kind of clumsy (and there's no PortletRequest.getProtocol()
)
We had those configuration properties in Resource Environment Provider for the purpose of generating external URLs for sending them in emails. It was specific solution and it wasn't a problem for us as we had other properties stored there as well so we knew it will be available at runtime. I don't know if that suits your needs. It depends on your scenario. Also, we used https only during login, so we always generated http URLs.
Hope this helps.