Deepak
Deepak

Reputation: 23

How to get the domain name of client accessing spring boot application?

I want to get the domain names who are accessing my application. I tried with :getHostName(),getServerName()... All gives the the domain of the Server, not the cient, I want to get domain name of client..

Upvotes: 2

Views: 6246

Answers (1)

Ebert Toribio
Ebert Toribio

Reputation: 181

You can inject HttpServletRequest in your controller's method and use

@GetMapping("/getInfo")
public void getRemoteHost(HttpServletRequest request,...) {
     System.out.println("=========> "+request.getRemoteAddr());
}

Upvotes: 2

Related Questions