To get the request URL, found below approaches in stack overflow.

1st approach:

```
@Autowired
private HttpServletRequest request;

public void getURL(){
String url=request.getRequestURL().toString();
}

```

2nd approach:

```
public void getURL(){
String url=ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString();
}

```

3rd approach:

```
public void getURL(){
HttpServletRequest request= 
((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
String url=request.getRequestURL().toString();
}

```

I am confused which one to use to get the request URL in the spring boot application.

if i go with 3rd approach, then should i need to create bean of RequestContextListener in Configuration class as shown below?

```
@Bean
public RequestContextListener requestContextListener(){
return new RequestContextListener();
}

```