Mayumi Mayumi - 1 year ago 169
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(); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download