As the request implements HttpServletRequest
you can access the URI directly by calling request.getRequestURI()
to use in in conjunction with Get domain name from given url answer.
Also, be sure to check out javadocs on HttpServletRequest
to find out other interesting methods like, for example, getServerName
.
As to the problem of how you can get what you need in JSP, not in servlet/scriptlet, you'd need to use JSTL fn:replace
function like this:
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
${fn:replace(request.serverName, 'www.','')}