Get the base URL through the Request Servlet Context
Get the base URL through the Request Servlet Context.
Javadoc available at https://www.javatapas.com/docs/javatapas/servlet/ServletGetBaseUrl.html
public static String servletGetBaseUrl(HttpServletRequest request){
ServletContext servletContext = request.getServletContext();
String urlPath = request.getScheme() +
"://" +
request.getServerName() + ":" +
request.getServerPort() +
servletContext.getServletContextName();
return urlPath;
}
}