to get client ip using servlet, we can use the code like

the userIpAddress will return the String representation…