问题
How do you get the source domain using HttpServletRequest? Source domain is the requester's domain.
Thanks.
回答1:
You could do either
// gets client (browser)'s hostname
String host = request.getRemoteHost();
OR
// get the server's domain name.
String domain = new URL(request.getRequestURL().toString()).getHost();
回答2:
Hostname request
InetAddress ip = InetAddress.getLocalHost();
String hostname = ip.getHostName();
out.print("Your current IP address : " + ip+"\n");
out.print("Your current Hostname : " + hostname);
来源:https://stackoverflow.com/questions/7246543/get-url-of-the-request-sender-with-httpservletrequest