[JAVA] [Kotlin] How to get IP address and user agent

import javax.servlet.http.HttpServletRequest

fun function(request: HttpServletRequest) {
    val ipAddress: String = request.remoteAddr // "127.0.0.1"
    val userAgent: String = request.getHeader("user-agent") // "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"
}

Recommended Posts

[Kotlin] How to get IP address and user agent
How to set the IP address and host name of CentOS8
IP address and port restrictions to Ubuntu
[Java] How to get and output standard input
How to get and study java SE8 Gold
[Rails] How to get success and error messages
How to install Gradle and Kotlin with SDKMAN (Mac)
[Ruby] How to get the tens place and the ones place
How to batch run JUnit and get coverage as well
How to use StringBurrer and Arrays.toString.
How to use Java HttpClient (Get)
[Rails] How to get the URL of the transition source and redirect
How to get started with slim
How to use EventBus3 and ThreadMode
How to apply IAM ROLE to EC2 and get temporary AccessKey and SecretAccessKey
[Swift5] How to get an array and the complement of arrays
Get country from IP address (Java)
How to get parameters in Spark
How to call classes and methods
How to use equality and equality (how to use equals)
How to connect Heroku and Sequel
How to convert LocalDate and Timestamp
How to get along with Rails
How to get and add data from Firebase Firestore in Ruby
[Java] How to convert from String to Path type and get the path
[Java] How to get the current date and time and specify the display format
How to display error messages and success messages when registering as a user
How to limit IP address only to a specific directory with laravel + nginx
[Rails] How to get the user information currently logged in with devise
I want to get the IP address when connecting to Wi-Fi in Java
How to create your own annotation in Java and get the value
How to get date data in Ruby
How to use OrientJS and OrientDB together
[Kotlin] 3 ways to get Class from KClass
[Note] How to get started with Rspec
[IOS] How to get data from DynamoDB
[Java] How to output and write files!
How to set up and use kapt
How to build SquashTM and how to support Japanese
How to find the tens and ones
How to get the date in java
[Easy] How to upgrade Ruby and bundler
How to use substring and substr methods
Note: [Docker] How to start and stop
How to write and explain Dockerfile, docker-compose
How to use @Builder and @NoArgsConstructor together
How to get the ID of a user authenticated with Firebase in Swift
[Spring sample code included] How to create a form and how to get multiple records
How to get only articles and transactions that you commented or messaged [includes]
JDBC promises and examples of how to write
[Ruby] How to convert from lowercase to uppercase and from uppercase to lowercase
How to get keycloak credentials in interceptor class
How to disable user operations during asynchronous processing
How to output Excel and PDF using Excella
[Java] How to use FileReader class and BufferedReader class
How to execute and mock methods using JUnit
How to get a heapdump from a Docker container
[Ruby] How to use gsub method and sub method
How to get today's day of the week
How to use Segmented Control and points to note
Git and GitHub ~ How to fix common errors ~