Last active
April 18, 2024 23:45
-
-
Save beradrian/d66008b6c5a784185c29 to your computer and use it in GitHub Desktop.
Get baseUrl for a servlet request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String getBaseUrl(HttpServletRequest request) { | |
String baseUrl = request.getRequestURL().substring(0, request.getRequestURL().length() - request.getRequestURI().length()) + request.getContextPath(); | |
return baseUrl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍