How to get client IP address in java Struts2

When users submit a form along with form data we can get the IP address of the client. Let’s see one simple program to demonstrate this request.getHeader(“X-FORWARDED-FOR”);  is used to get the address of client in java/jsp/struts and in spring.