How can I get the complete URL address (like "www.jguru.com" (with or without "http://")) from a HttpServletRequest?
Created May 7, 2012
JIA Java Italian Association Have you considered checking the documentation for HttpServletRequest?
It's unbelievable how much interesting stuff you can find. Something like this:
It's unbelievable how much interesting stuff you can find. Something like this:
public java.lang.StringBuffer getRequestUrl()
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters [...].
If you want to extract only the domain name (www.jguru.com) from the url, use getServerName().