Without using an external API, it is not possible to retrieve the location information of a user directly from a HttpServletRequest object in Java.
The HttpServletRequest object only contains information that is sent in the HTTP request headers, such as the IP address and user agent. However, this information alone is not sufficient to determine the location of the user.
IP geolocation requires a mapping between IP addresses and physical locations, and this mapping is usually maintained by third-party IP geolocation services. These services maintain large databases of IP addresses and their corresponding physical locations, and use sophisticated algorithms to determine the most likely location of a given IP address.
While it is possible to build your own database of IP addresses and their corresponding locations, this would be a challenging and time-consuming task, as IP addresses are constantly being reassigned and physical locations can change over time. Additionally, building and maintaining such a database would likely require significant financial resources.
Therefore, using a third-party IP geolocation service is the most practical option for obtaining location information from a HttpServletRequest object in Java.