Mayumi Mayumi - 1 year ago 117
Java Question

Get URL of the request sender with HttpServletRequest

How do you get the source domain using HttpServletRequest?
Source domain is the requester's domain.


Answer Source

You could do either

// gets client (browser)'s hostname
String host = request.getRemoteHost(); 


// get the server's domain name.
String domain = new URL(request.getRequestURL().toString()).getHost();