How to get host name with port from a http or https request
You can use HttpServletRequest.getScheme() to retrieve either “http” or “https”. Using it along with HttpServletRequest.getServerName() should be enough to rebuild the portion of the URL you need. You don’t need to explicitly put the port in the URL if you’re using the standard ones (80 for http and 443 for https). Edit: If your servlet … Read more